+Sun Mar 18 01:15:30 2001 Tim Janik <timj@gtk.org>
+
+ * gtk/gtkspinbutton.[hc]: added rc-style argument
+ GtkSpinButton::shadow_type.
+ removed spin_button->shadow_type, gtk_spin_button_set_shadow_type()
+ and ARG_SHADOW_TYPE as it doesn' make much sense to try to override
+ rc-style settings.
+
+ * gtk/gtkfixed.c: removed gtk_fixed_paint() (was unused).
+
+ * gtk/gtkwidget.c: quark cleanups.
+
+ * gtk/gtkrc.[hc]: added gtk_rc_scanner_new() to create an rc-file
+ scanner with appropriate configuration, renamed GtkRcStyleClass.clone
+ to create_rc_style() (we don't do cloning in standard OO sense).
+ added per rc style properties.
+
+ * gtk/gtkstyle.[hc]: added code to retrive pspec conformant rc-style
+ property values and for caching those. some cleanups.
+
+ * gtk/Makefile.am: -DG_DISABLE_CONST_RETURNS.
+
+ * gtk/gtksettings.[hc]: new file for global rc-file properties
+ (at least currently, should get extended to support X properties
+ and other communication mechanisms).
+
+ * gtk/gtkwidget.[hc]: added style property support:
+ (gtk_widget_class_install_style_property_parser): install style
+ property pspec with parser function for rc-file values other
+ than LONG, DOUBLE or STRING.
+ (gtk_widget_class_install_style_property): same as above without
+ parser (parsers are going to be needed quite infrequently).
+ (gtk_widget_style_get_property): retrive style property value.
+ (gtk_widget_style_get_valist): same as above with varargs support,
+ has NOCOPY semantics.
+ (gtk_widget_style_get): wrapper around gtk_widget_style_get_valist().
+
Fri Mar 16 18:24:53 2001 Jonathan Blandford <jrb@redhat.com>
* demos/gtk-demo/main.c (row_activated_cb): modified to use
+Sun Mar 18 01:15:30 2001 Tim Janik <timj@gtk.org>
+
+ * gtk/gtkspinbutton.[hc]: added rc-style argument
+ GtkSpinButton::shadow_type.
+ removed spin_button->shadow_type, gtk_spin_button_set_shadow_type()
+ and ARG_SHADOW_TYPE as it doesn' make much sense to try to override
+ rc-style settings.
+
+ * gtk/gtkfixed.c: removed gtk_fixed_paint() (was unused).
+
+ * gtk/gtkwidget.c: quark cleanups.
+
+ * gtk/gtkrc.[hc]: added gtk_rc_scanner_new() to create an rc-file
+ scanner with appropriate configuration, renamed GtkRcStyleClass.clone
+ to create_rc_style() (we don't do cloning in standard OO sense).
+ added per rc style properties.
+
+ * gtk/gtkstyle.[hc]: added code to retrive pspec conformant rc-style
+ property values and for caching those. some cleanups.
+
+ * gtk/Makefile.am: -DG_DISABLE_CONST_RETURNS.
+
+ * gtk/gtksettings.[hc]: new file for global rc-file properties
+ (at least currently, should get extended to support X properties
+ and other communication mechanisms).
+
+ * gtk/gtkwidget.[hc]: added style property support:
+ (gtk_widget_class_install_style_property_parser): install style
+ property pspec with parser function for rc-file values other
+ than LONG, DOUBLE or STRING.
+ (gtk_widget_class_install_style_property): same as above without
+ parser (parsers are going to be needed quite infrequently).
+ (gtk_widget_style_get_property): retrive style property value.
+ (gtk_widget_style_get_valist): same as above with varargs support,
+ has NOCOPY semantics.
+ (gtk_widget_style_get): wrapper around gtk_widget_style_get_valist().
+
Fri Mar 16 18:24:53 2001 Jonathan Blandford <jrb@redhat.com>
* demos/gtk-demo/main.c (row_activated_cb): modified to use
+Sun Mar 18 01:15:30 2001 Tim Janik <timj@gtk.org>
+
+ * gtk/gtkspinbutton.[hc]: added rc-style argument
+ GtkSpinButton::shadow_type.
+ removed spin_button->shadow_type, gtk_spin_button_set_shadow_type()
+ and ARG_SHADOW_TYPE as it doesn' make much sense to try to override
+ rc-style settings.
+
+ * gtk/gtkfixed.c: removed gtk_fixed_paint() (was unused).
+
+ * gtk/gtkwidget.c: quark cleanups.
+
+ * gtk/gtkrc.[hc]: added gtk_rc_scanner_new() to create an rc-file
+ scanner with appropriate configuration, renamed GtkRcStyleClass.clone
+ to create_rc_style() (we don't do cloning in standard OO sense).
+ added per rc style properties.
+
+ * gtk/gtkstyle.[hc]: added code to retrive pspec conformant rc-style
+ property values and for caching those. some cleanups.
+
+ * gtk/Makefile.am: -DG_DISABLE_CONST_RETURNS.
+
+ * gtk/gtksettings.[hc]: new file for global rc-file properties
+ (at least currently, should get extended to support X properties
+ and other communication mechanisms).
+
+ * gtk/gtkwidget.[hc]: added style property support:
+ (gtk_widget_class_install_style_property_parser): install style
+ property pspec with parser function for rc-file values other
+ than LONG, DOUBLE or STRING.
+ (gtk_widget_class_install_style_property): same as above without
+ parser (parsers are going to be needed quite infrequently).
+ (gtk_widget_style_get_property): retrive style property value.
+ (gtk_widget_style_get_valist): same as above with varargs support,
+ has NOCOPY semantics.
+ (gtk_widget_style_get): wrapper around gtk_widget_style_get_valist().
+
Fri Mar 16 18:24:53 2001 Jonathan Blandford <jrb@redhat.com>
* demos/gtk-demo/main.c (row_activated_cb): modified to use
+Sun Mar 18 01:15:30 2001 Tim Janik <timj@gtk.org>
+
+ * gtk/gtkspinbutton.[hc]: added rc-style argument
+ GtkSpinButton::shadow_type.
+ removed spin_button->shadow_type, gtk_spin_button_set_shadow_type()
+ and ARG_SHADOW_TYPE as it doesn' make much sense to try to override
+ rc-style settings.
+
+ * gtk/gtkfixed.c: removed gtk_fixed_paint() (was unused).
+
+ * gtk/gtkwidget.c: quark cleanups.
+
+ * gtk/gtkrc.[hc]: added gtk_rc_scanner_new() to create an rc-file
+ scanner with appropriate configuration, renamed GtkRcStyleClass.clone
+ to create_rc_style() (we don't do cloning in standard OO sense).
+ added per rc style properties.
+
+ * gtk/gtkstyle.[hc]: added code to retrive pspec conformant rc-style
+ property values and for caching those. some cleanups.
+
+ * gtk/Makefile.am: -DG_DISABLE_CONST_RETURNS.
+
+ * gtk/gtksettings.[hc]: new file for global rc-file properties
+ (at least currently, should get extended to support X properties
+ and other communication mechanisms).
+
+ * gtk/gtkwidget.[hc]: added style property support:
+ (gtk_widget_class_install_style_property_parser): install style
+ property pspec with parser function for rc-file values other
+ than LONG, DOUBLE or STRING.
+ (gtk_widget_class_install_style_property): same as above without
+ parser (parsers are going to be needed quite infrequently).
+ (gtk_widget_style_get_property): retrive style property value.
+ (gtk_widget_style_get_valist): same as above with varargs support,
+ has NOCOPY semantics.
+ (gtk_widget_style_get): wrapper around gtk_widget_style_get_valist().
+
Fri Mar 16 18:24:53 2001 Jonathan Blandford <jrb@redhat.com>
* demos/gtk-demo/main.c (row_activated_cb): modified to use
+Sun Mar 18 01:15:30 2001 Tim Janik <timj@gtk.org>
+
+ * gtk/gtkspinbutton.[hc]: added rc-style argument
+ GtkSpinButton::shadow_type.
+ removed spin_button->shadow_type, gtk_spin_button_set_shadow_type()
+ and ARG_SHADOW_TYPE as it doesn' make much sense to try to override
+ rc-style settings.
+
+ * gtk/gtkfixed.c: removed gtk_fixed_paint() (was unused).
+
+ * gtk/gtkwidget.c: quark cleanups.
+
+ * gtk/gtkrc.[hc]: added gtk_rc_scanner_new() to create an rc-file
+ scanner with appropriate configuration, renamed GtkRcStyleClass.clone
+ to create_rc_style() (we don't do cloning in standard OO sense).
+ added per rc style properties.
+
+ * gtk/gtkstyle.[hc]: added code to retrive pspec conformant rc-style
+ property values and for caching those. some cleanups.
+
+ * gtk/Makefile.am: -DG_DISABLE_CONST_RETURNS.
+
+ * gtk/gtksettings.[hc]: new file for global rc-file properties
+ (at least currently, should get extended to support X properties
+ and other communication mechanisms).
+
+ * gtk/gtkwidget.[hc]: added style property support:
+ (gtk_widget_class_install_style_property_parser): install style
+ property pspec with parser function for rc-file values other
+ than LONG, DOUBLE or STRING.
+ (gtk_widget_class_install_style_property): same as above without
+ parser (parsers are going to be needed quite infrequently).
+ (gtk_widget_style_get_property): retrive style property value.
+ (gtk_widget_style_get_valist): same as above with varargs support,
+ has NOCOPY semantics.
+ (gtk_widget_style_get): wrapper around gtk_widget_style_get_valist().
+
Fri Mar 16 18:24:53 2001 Jonathan Blandford <jrb@redhat.com>
* demos/gtk-demo/main.c (row_activated_cb): modified to use
+Sun Mar 18 01:15:30 2001 Tim Janik <timj@gtk.org>
+
+ * gtk/gtkspinbutton.[hc]: added rc-style argument
+ GtkSpinButton::shadow_type.
+ removed spin_button->shadow_type, gtk_spin_button_set_shadow_type()
+ and ARG_SHADOW_TYPE as it doesn' make much sense to try to override
+ rc-style settings.
+
+ * gtk/gtkfixed.c: removed gtk_fixed_paint() (was unused).
+
+ * gtk/gtkwidget.c: quark cleanups.
+
+ * gtk/gtkrc.[hc]: added gtk_rc_scanner_new() to create an rc-file
+ scanner with appropriate configuration, renamed GtkRcStyleClass.clone
+ to create_rc_style() (we don't do cloning in standard OO sense).
+ added per rc style properties.
+
+ * gtk/gtkstyle.[hc]: added code to retrive pspec conformant rc-style
+ property values and for caching those. some cleanups.
+
+ * gtk/Makefile.am: -DG_DISABLE_CONST_RETURNS.
+
+ * gtk/gtksettings.[hc]: new file for global rc-file properties
+ (at least currently, should get extended to support X properties
+ and other communication mechanisms).
+
+ * gtk/gtkwidget.[hc]: added style property support:
+ (gtk_widget_class_install_style_property_parser): install style
+ property pspec with parser function for rc-file values other
+ than LONG, DOUBLE or STRING.
+ (gtk_widget_class_install_style_property): same as above without
+ parser (parsers are going to be needed quite infrequently).
+ (gtk_widget_style_get_property): retrive style property value.
+ (gtk_widget_style_get_valist): same as above with varargs support,
+ has NOCOPY semantics.
+ (gtk_widget_style_get): wrapper around gtk_widget_style_get_valist().
+
Fri Mar 16 18:24:53 2001 Jonathan Blandford <jrb@redhat.com>
* demos/gtk-demo/main.c (row_activated_cb): modified to use
+Sun Mar 18 01:15:30 2001 Tim Janik <timj@gtk.org>
+
+ * gtk/gtkspinbutton.[hc]: added rc-style argument
+ GtkSpinButton::shadow_type.
+ removed spin_button->shadow_type, gtk_spin_button_set_shadow_type()
+ and ARG_SHADOW_TYPE as it doesn' make much sense to try to override
+ rc-style settings.
+
+ * gtk/gtkfixed.c: removed gtk_fixed_paint() (was unused).
+
+ * gtk/gtkwidget.c: quark cleanups.
+
+ * gtk/gtkrc.[hc]: added gtk_rc_scanner_new() to create an rc-file
+ scanner with appropriate configuration, renamed GtkRcStyleClass.clone
+ to create_rc_style() (we don't do cloning in standard OO sense).
+ added per rc style properties.
+
+ * gtk/gtkstyle.[hc]: added code to retrive pspec conformant rc-style
+ property values and for caching those. some cleanups.
+
+ * gtk/Makefile.am: -DG_DISABLE_CONST_RETURNS.
+
+ * gtk/gtksettings.[hc]: new file for global rc-file properties
+ (at least currently, should get extended to support X properties
+ and other communication mechanisms).
+
+ * gtk/gtkwidget.[hc]: added style property support:
+ (gtk_widget_class_install_style_property_parser): install style
+ property pspec with parser function for rc-file values other
+ than LONG, DOUBLE or STRING.
+ (gtk_widget_class_install_style_property): same as above without
+ parser (parsers are going to be needed quite infrequently).
+ (gtk_widget_style_get_property): retrive style property value.
+ (gtk_widget_style_get_valist): same as above with varargs support,
+ has NOCOPY semantics.
+ (gtk_widget_style_get): wrapper around gtk_widget_style_get_valist().
+
Fri Mar 16 18:24:53 2001 Jonathan Blandford <jrb@redhat.com>
* demos/gtk-demo/main.c (row_activated_cb): modified to use
GdkDrawableImplX11
GdkWindowImplX11
GdkColormap
- GtkRcStyle
+ GtkSettings
GdkPixbufLoader
GdkWindowImplX11
GdkPixmap
GdkColormap
+ GtkSettings
GtkObject
GtkWidget
GtkMisc
</para>
+<!-- ##### MACRO GTK_TYPE_TREE_COLUMN ##### -->
+<para>
+
+</para>
+
+
<!-- ##### MACRO GTK_VALUE_ARGS ##### -->
<para>
Use to get the value of a GtkArg whose GtkType is GTK_TYPE_ARGS
</para>
-<!-- ##### USER_FUNCTION GtkEmissionHook ##### -->
-<para>
-A simple function pointer to get invoked when the
-signal is emitted. This allows you tie a hook to the signal type,
-so that it will trap all emissions of that signal, from any object.
-</para>
-<para>
-You may not attach these to signals created with the
-#GTK_RUN_NO_HOOKS flag.
-</para>
-
-@object:
-@signal_id:
-@n_params:
-@params:
-@data:
-@Returns:
-
<!-- ##### ENUM GtkFontFilterType ##### -->
<para>
A set of bit flags used to specify the filter being set
@nparams:
@params:
+<!-- ##### ARG GtkSpinButton:shadow-type ##### -->
+<para>
+the type of border that surrounds the arrows of a spin button.
+</para>
+
+
<!-- ##### STRUCT GtkStatusbarMsg ##### -->
<para>
Holds the data for a statusbar message. <structfield>text</structfield> holds the actual text string. <structfield>context_id</structfield> is the context that this message is associated with, and <structfield>message_id</structfield> is this particular message's identifier. However, these fields should not be modified directly.
</para>
+<!-- ##### ARG GtkTextView:justify ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### ARG GtkTextView:wrap-mode ##### -->
+<para>
+
+</para>
+
+
<!-- ##### SIGNAL GtkWidget::debug-msg ##### -->
<para>
@ruler: the gtkruler
-<!-- ##### FUNCTION gtk_signal_add_emission_hook ##### -->
-<para>
-Add an emission hook for a type of signal, for any object.
-</para>
-
-@signal_id: the type of signal to hook for.
-@hook_func: the function to invoke to handle the emission hook.
-@data: the user data passed in to hook_func.
-@Returns: the id (that you may pass as a parameter
-to gtk_signal_remove_emission_hook()).
-@i:
-@h:
-@d:
-
<!-- ##### FUNCTION gtk_signal_add_emission_hook_full ##### -->
<para>
Add an emission hook for a type of signal, for any object.
@object: the object whose signal handlers should be destroyed.
-<!-- ##### FUNCTION gtk_signal_init ##### -->
-<para>
-
-</para>
-
-
<!-- ##### FUNCTION gtk_signal_n_emissions ##### -->
<para>
Find out the recursion depth of emissions for a particular type
which contains all the information, or NULL.
The pointer is allocated just for you: you must g_free() it.
-<!-- ##### FUNCTION gtk_signal_remove_emission_hook ##### -->
-<para>
-Delete an emission hook. (see gtk_signal_add_emission_hook())
-</para>
-
-@signal_id: the id of the signal type.
-@hook_id: the id of the emission handler, returned by add_emission_hook().
-@i:
-@h:
-
<!-- ##### FUNCTION gtk_signal_set_funcs ##### -->
<para>
These set default functions to call when the user didn't
@destroy_func: the function to invoke when each hook is destroyed.
May be NULL.
+<!-- ##### FUNCTION gtk_spin_button_set_shadow_type ##### -->
+<para>
+Creates a border around the arrows of a #GtkSpinButton. The type of border is determined by @shadow_type.
+</para>
+
+@spin_button: a #GtkSpinButton
+@shadow_type: the new border type.
+
<!-- ##### FUNCTION gtk_trace_referencing ##### -->
<para>
Private: print debugging information while doing a gtk_object_ref() or
@field:
+<!-- ##### USER_FUNCTION GtkEmissionHook ##### -->
+<para>
+A simple function pointer to get invoked when the
+signal is emitted. This allows you tie a hook to the signal type,
+so that it will trap all emissions of that signal, from any object.
+</para>
+<para>
+You may not attach these to signals created with the
+#GTK_RUN_NO_HOOKS flag.
+</para>
+
+@object:
+@signal_id:
+@n_params:
+@params:
+@data:
+@Returns:
+
+
<!-- ##### ENUM GtkSignalRunType ##### -->
<para>
These configure the signal's emission. They control
@GTK_RUN_ACTION:
@GTK_RUN_NO_HOOKS:
+<!-- ##### FUNCTION gtk_signal_init ##### -->
+<para>
+
+</para>
+
+
+
<!-- ##### FUNCTION gtk_signal_new ##### -->
<para>
Create a new signal type. (This is usually done in the
the callbacks.
-<!-- ##### MACRO gtk_signal_lookup ##### -->
+<!-- ##### FUNCTION gtk_signal_lookup ##### -->
<para>
Given the name of the signal and the type of object it connects
to, get the signal's identifying integer. Emitting the signal
It also tries the ancestors of the given type.
</para>
-@Returns: the signal's identifying number, or 0 if no signal was found.
-<!-- # Unused Parameters # -->
@name: the signal's name, e.g. clicked.
@object_type: the type that the signal operates on, e.g. #GTK_TYPE_BUTTON.
+@Returns: the signal's identifying number, or 0 if no signal was found.
-<!-- ##### MACRO gtk_signal_name ##### -->
+<!-- ##### FUNCTION gtk_signal_name ##### -->
<para>
Given the signal's identifier, find its name.
</para>
Two different signals may have the same name, if they have differing types.
</para>
-@Returns: the signal name, or NULL if the signal number was invalid.
-<!-- # Unused Parameters # -->
@signal_id: the signal's identifying number.
+@Returns: the signal name, or NULL if the signal number was invalid.
<!-- ##### FUNCTION gtk_signal_emit ##### -->
followed by one which is a pointer to the return type.
-<!-- ##### MACRO gtk_signal_emit_stop ##### -->
+<!-- ##### FUNCTION gtk_signal_emit_stop ##### -->
<para>
This function aborts a signal's current emission.
</para>
isn't being emitted.
</para>
-@i:
-@s:
-<!-- # Unused Parameters # -->
@object: the object whose signal handlers you wish to stop.
@signal_id: the signal identifier, as returned by gtk_signal_lookup().
+<!-- # Unused Parameters # -->
+@i:
+@s:
<!-- ##### FUNCTION gtk_signal_emit_stop_by_name ##### -->
@name: the name of the signal you wish to stop.
-<!-- ##### MACRO gtk_signal_connect ##### -->
+<!-- ##### FUNCTION gtk_signal_connect ##### -->
<para>
Attach a function pointer and user data to a signal for
a particular object.
</programlisting>
</informalexample>
-@o:
-@s:
-@f:
-@d:
-@Returns: the connection id.
-<!-- # Unused Parameters # -->
@object: the object associated with the signal, e.g. if a button
is getting pressed, this is that button.
@name: name of the signal.
@func: function pointer to attach to the signal.
@func_data: value to pass as to your function (through the marshaller).
+@Returns: the connection id.
+<!-- # Unused Parameters # -->
+@o:
+@s:
+@f:
+@d:
-<!-- ##### MACRO gtk_signal_connect_after ##### -->
+<!-- ##### FUNCTION gtk_signal_connect_after ##### -->
<para>
Attach a function pointer and user data to a signal
so that this handler will be called after the other handlers.
</para>
-@o:
-@s:
-@f:
-@d:
-@Returns: the unique identifier for this attachment: the connection id.
-<!-- # Unused Parameters # -->
@object: the object associated with the signal.
@name: name of the signal.
@func: function pointer to attach to the signal.
@func_data: value to pass as to your function (through the marshaller).
+@Returns: the unique identifier for this attachment: the connection id.
+<!-- # Unused Parameters # -->
+@o:
+@s:
+@f:
+@d:
-<!-- ##### MACRO gtk_signal_connect_object ##### -->
+<!-- ##### FUNCTION gtk_signal_connect_object ##### -->
<para>
This function is for registering a callback that will
call another object's callback. That is,
</programlisting>
</informalexample>
-@o:
-@s:
-@f:
-@d:
-@Returns: the connection id.
-<!-- # Unused Parameters # -->
@object: the object which emits the signal.
@name: the name of the signal.
@func: the function to callback.
@slot_object: the object to pass as the first parameter to func.
(Though it pretends to take an object, you can
really pass any gpointer as the #slot_object .)
+@Returns: the connection id.
+<!-- # Unused Parameters # -->
+@o:
+@s:
+@f:
+@d:
-<!-- ##### MACRO gtk_signal_connect_object_after ##### -->
+<!-- ##### FUNCTION gtk_signal_connect_object_after ##### -->
<para>
Attach a signal hook to a signal, passing in an alternate
object as the first parameter, and guaranteeing
handlers are called first.
</para>
-@o:
-@s:
-@f:
-@d:
-@Returns: the connection id.
-<!-- # Unused Parameters # -->
@object: the object associated with the signal.
@name: name of the signal.
@func: function pointer to attach to the signal.
@slot_object: the object to pass as the first parameter to #func.
+@Returns: the connection id.
+<!-- # Unused Parameters # -->
+@o:
+@s:
+@f:
+@d:
<!-- ##### FUNCTION gtk_signal_connect_full ##### -->
@name: name of the signal.
-<!-- ##### MACRO gtk_signal_disconnect ##### -->
+<!-- ##### FUNCTION gtk_signal_disconnect ##### -->
<para>
Destroy a user-defined handler connection.
</para>
-<!-- # Unused Parameters # -->
@object: the object which the handler pertains to.
@handler_id: the connection id.
-<!-- ##### MACRO gtk_signal_disconnect_by_func ##### -->
+<!-- ##### FUNCTION gtk_signal_disconnect_by_func ##### -->
<para>
Destroy all connections for a particular object, with
the given function-pointer and user-data.
</para>
-@o:
-@f:
-@d:
-<!-- # Unused Parameters # -->
@object: the object which emits the signal.
@func: the function pointer to search for.
@data: the user data to search for.
+<!-- # Unused Parameters # -->
+@o:
+@f:
+@d:
-<!-- ##### MACRO gtk_signal_disconnect_by_data ##### -->
+<!-- ##### FUNCTION gtk_signal_disconnect_by_data ##### -->
<para>
Destroy all connections for a particular object, with
the given user-data.
</para>
-@o:
-@d:
-<!-- # Unused Parameters # -->
@object: the object which emits the signal.
@data: the user data to search for.
+<!-- # Unused Parameters # -->
+@o:
+@d:
-<!-- ##### MACRO gtk_signal_handler_block ##### -->
+<!-- ##### FUNCTION gtk_signal_handler_block ##### -->
<para>
Prevent an user-defined handler from being invoked. All other
signal processing will go on as normal, but this particular
handler will ignore it.
</para>
-<!-- # Unused Parameters # -->
@object: the object which emits the signal to block.
@handler_id: the connection id.
-<!-- ##### MACRO gtk_signal_handler_block_by_func ##### -->
+<!-- ##### FUNCTION gtk_signal_handler_block_by_func ##### -->
<para>
Prevent a user-defined handler from being invoked, by reference to
the user-defined handler's function pointer and user data. (It may result in
multiple hooks being blocked, if you've called connect multiple times.)
</para>
-@o:
-@f:
-@d:
-<!-- # Unused Parameters # -->
@object: the object which emits the signal to block.
@func: the function pointer of the handler to block.
@data: the user data of the handler to block.
+<!-- # Unused Parameters # -->
+@o:
+@f:
+@d:
-<!-- ##### MACRO gtk_signal_handler_block_by_data ##### -->
+<!-- ##### FUNCTION gtk_signal_handler_block_by_data ##### -->
<para>
Prevent all user-defined handlers with a certain user data from being invoked.
</para>
-@o:
-@d:
-<!-- # Unused Parameters # -->
@object: the object which emits the signal we want to block.
@data: the user data of the handlers to block.
+<!-- # Unused Parameters # -->
+@o:
+@d:
-<!-- ##### MACRO gtk_signal_handler_unblock ##### -->
+<!-- ##### FUNCTION gtk_signal_handler_unblock ##### -->
<para>
Undo a block, by connection id. Note that undoing a block doesn't
necessarily make the hook callable, because if you block a
hook twice, you must unblock it twice.
</para>
-<!-- # Unused Parameters # -->
@object: the object which emits the signal we want to unblock.
@handler_id: the emission handler identifier, as returned by
gtk_signal_connect(), etc.
-<!-- ##### MACRO gtk_signal_handler_unblock_by_func ##### -->
+<!-- ##### FUNCTION gtk_signal_handler_unblock_by_func ##### -->
<para>
Undo a block, by function pointer and data.
Note that undoing a block doesn't
hook twice, you must unblock it twice.
</para>
-@o:
-@f:
-@d:
-<!-- # Unused Parameters # -->
@object: the object which emits the signal we want to unblock.
@func: the function pointer to search for.
@data: the user data to search for.
+<!-- # Unused Parameters # -->
+@o:
+@f:
+@d:
-<!-- ##### MACRO gtk_signal_handler_unblock_by_data ##### -->
+<!-- ##### FUNCTION gtk_signal_handler_unblock_by_data ##### -->
<para>
Undo block(s), to all signals for a particular object
with a particular user-data pointer
</para>
-@o:
-@d:
-<!-- # Unused Parameters # -->
@object: the object which emits the signal we want to unblock.
@data: the user data to search for.
+<!-- # Unused Parameters # -->
+@o:
+@d:
-<!-- ##### MACRO gtk_signal_handler_pending ##### -->
+<!-- ##### FUNCTION gtk_signal_handler_pending ##### -->
<para>
Returns a connection id corresponding to a given signal id and object.
</para>
thus saving the cost of building the arguments.
</para>
-@i:
-@s:
-@b:
-@Returns: the connection id, if a connection was found. 0 otherwise.
-<!-- # Unused Parameters # -->
@object: the object to search for the desired user-defined handler.
@signal_id: the number of the signal to search for.
@may_be_blocked: whether it is acceptable to return a blocked
handler.
+@Returns: the connection id, if a connection was found. 0 otherwise.
+<!-- # Unused Parameters # -->
+@i:
+@s:
+@b:
-<!-- ##### MACRO gtk_signal_handler_pending_by_func ##### -->
+<!-- ##### FUNCTION gtk_signal_handler_pending_by_func ##### -->
<para>
Returns a connection id corresponding to a given signal id, object, function
pointer and user data.
</para>
-@o:
-@s:
-@b:
-@f:
-@d:
-@Returns: the connection id, if a handler was found. 0 otherwise.
-<!-- # Unused Parameters # -->
@object: the object to search for the desired handler.
@signal_id: the number of the signal to search for.
@may_be_blocked: whether it is acceptable to return a blocked
handler.
@func: the function pointer to search for.
@data: the user data to search for.
+@Returns: the connection id, if a handler was found. 0 otherwise.
+<!-- # Unused Parameters # -->
+@o:
+@s:
+@b:
+@f:
+@d:
+
+
+<!-- ##### FUNCTION gtk_signal_add_emission_hook ##### -->
+<para>
+Add an emission hook for a type of signal, for any object.
+</para>
+
+@signal_id: the type of signal to hook for.
+@hook_func: the function to invoke to handle the emission hook.
+@data: the user data passed in to hook_func.
+@Returns: the id (that you may pass as a parameter
+to gtk_signal_remove_emission_hook()).
+<!-- # Unused Parameters # -->
+@i:
+@h:
+@d:
+
+
+<!-- ##### FUNCTION gtk_signal_remove_emission_hook ##### -->
+<para>
+Delete an emission hook. (see gtk_signal_add_emission_hook())
+</para>
+
+@signal_id: the id of the signal type.
+@hook_id: the id of the emission handler, returned by add_emission_hook().
+<!-- # Unused Parameters # -->
+@i:
+@h:
<!-- ##### MACRO gtk_signal_default_marshaller ##### -->
@wrap: defaults to FALSE, set to TRUE to make the spin button wrap.
-<!-- ##### FUNCTION gtk_spin_button_set_shadow_type ##### -->
-<para>
-Creates a border around the arrows of a #GtkSpinButton. The type of border is determined by @shadow_type.
-</para>
-
-@spin_button: a #GtkSpinButton
-@shadow_type: the new border type.
-
-
<!-- ##### FUNCTION gtk_spin_button_set_snap_to_ticks ##### -->
<para>
Sets whether a number typed into a spin button should be snapped to the nearest step increment.
how a spin button should be updated.
</para>
-<!-- ##### ARG GtkSpinButton:shadow-type ##### -->
-<para>
-the type of border that surrounds the arrows of a spin button.
-</para>
-
<!-- ##### ARG GtkSpinButton:value ##### -->
<para>
reads the current value, or sets a new value.
</para>
-<!-- ##### ARG GtkTextView:wrap-mode ##### -->
-<para>
-
-</para>
-
-<!-- ##### ARG GtkTextView:justify ##### -->
-<para>
-
-</para>
-
<!-- ##### ARG GtkTextView:left-margin ##### -->
<para>
</para>
-<!-- ##### MACRO GTK_TYPE_TREE_COLUMN ##### -->
-<para>
-
-</para>
-
-
-
<!-- ##### STRUCT GtkTreeViewColumn ##### -->
<para>
@type_info: must not be null, and @type_info->type_name must also not be null.
-<!-- ##### MACRO gtk_type_name ##### -->
+<!-- ##### FUNCTION gtk_type_name ##### -->
<para>
</para>
-@Returns: a pointer to the name of a type, or NULL if it has none.
-<!-- # Unused Parameters # -->
@type: a GtkType
+@Returns: a pointer to the name of a type, or NULL if it has none.
-<!-- ##### MACRO gtk_type_from_name ##### -->
+<!-- ##### FUNCTION gtk_type_from_name ##### -->
<para>
Get the internal representation of a type given its name.
</para>
-@Returns: a GtkType
-<!-- # Unused Parameters # -->
@name: the name of a gtk type
+@Returns: a GtkType
-<!-- ##### MACRO gtk_type_parent ##### -->
+<!-- ##### FUNCTION gtk_type_parent ##### -->
<para>
</para>
-@Returns: the GtkType of the parent
-<!-- # Unused Parameters # -->
@type: a GtkType
+@Returns: the GtkType of the parent
<!-- ##### FUNCTION gtk_type_class ##### -->
@Returns: gpointer to a GtkTypeObject
-<!-- ##### MACRO gtk_type_is_a ##### -->
+<!-- ##### FUNCTION gtk_type_is_a ##### -->
<para>
Look in the type hierarchy to see if @type has @is_a_type among its
ancestors. Do so with a simple lookup, not a loop.
</para>
-@Returns:
-<!-- # Unused Parameters # -->
@type: GtkType
@is_a_type: GtkType
+@Returns:
<!-- ##### FUNCTION gtk_type_enum_get_values ##### -->
-DGTK_LOCALEDIR=\"$(gtklocaledir)\" \
-DGTK_VERSION=\"@GTK_VERSION@\" \
-DTESTGTK_RCFILE=\"`pwd`/$(srcdir)/testgtkrc\" \
+ -DG_DISABLE_CONST_RETURNS \
-I$(top_builddir)/gtk \
-I$(top_srcdir) -I../gdk \
-I$(top_srcdir)/gdk \
gtkscrolledwindow.h \
gtkselection.h \
gtkseparator.h \
+ gtksettings.h \
gtksignal.h \
gtksocket.h \
gtkspinbutton.h \
gtkscrolledwindow.c \
gtkselection.c \
gtkseparator.c \
+ gtksettings.c \
gtksignal.c \
gtksocket.c \
gtkspinbutton.c \
#include <gtk/gtkselection.h>
#include <gtk/gtkseparator.h>
#include <gtk/gtkseparatormenuitem.h>
+#include <gtk/gtksettings.h>
#include <gtk/gtksignal.h>
#include <gtk/gtksocket.h>
#include <gtk/gtkspinbutton.h>
GdkEventKey *event,
GtkCombo *combo)
{
- GList *li;
-
if (event->keyval == GDK_Return || event->keyval == GDK_KP_Enter)
{
if (GTK_WIDGET_VISIBLE (combo->popwin))
GtkRequisition *requisition);
static void gtk_fixed_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
-static void gtk_fixed_paint (GtkWidget *widget,
- GdkRectangle *area);
static void gtk_fixed_add (GtkContainer *container,
GtkWidget *widget);
static void gtk_fixed_remove (GtkContainer *container,
}
}
-static void
-gtk_fixed_paint (GtkWidget *widget,
- GdkRectangle *area)
-{
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GTK_IS_FIXED (widget));
- g_return_if_fail (area != NULL);
-
- if (GTK_WIDGET_DRAWABLE (widget))
- gdk_window_clear_area (widget->window,
- area->x, area->y,
- area->width, area->height);
-}
-
static void
gtk_fixed_add (GtkContainer *container,
GtkWidget *widget)
#include "gtkthemes.h"
#include "gtkintl.h"
#include "gtkiconfactory.h"
+#include "gtksettings.h"
#ifdef G_OS_WIN32
#include <io.h>
const gchar *input_string);
static guint gtk_rc_parse_statement (GScanner *scanner);
static guint gtk_rc_parse_style (GScanner *scanner);
+static guint gtk_rc_parse_assignment (GScanner *scanner,
+ GtkRcProperty *prop);
static guint gtk_rc_parse_bg (GScanner *scanner,
GtkRcStyle *style);
static guint gtk_rc_parse_fg (GScanner *scanner,
static void gtk_rc_style_finalize (GObject *object);
static void gtk_rc_style_real_merge (GtkRcStyle *dest,
GtkRcStyle *src);
-static GtkRcStyle *gtk_rc_style_real_clone (GtkRcStyle *rc_style);
-static GtkStyle * gtk_rc_style_real_create_style (GtkRcStyle *rc_style);
+static GtkRcStyle* gtk_rc_style_real_create_rc_style (GtkRcStyle *rc_style);
+static GtkStyle* gtk_rc_style_real_create_style (GtkRcStyle *rc_style);
+static gint gtk_rc_properties_cmp (gconstpointer bsearch_node1,
+ gconstpointer bsearch_node2);
static gpointer parent_class = NULL;
-static const GScannerConfig gtk_rc_scanner_config =
+static const GScannerConfig gtk_rc_scanner_config =
{
(
" \t\r\n"
#ifdef G_OS_WIN32
-
static gchar *
get_gtk_dll_name (void)
{
get_gtk_dll_name (),
"themes");
}
-
-#endif
+#endif /* G_OS_WIN32 */
static gchar *
gtk_rc_make_default_dir (const gchar *type)
void
gtk_rc_init (void)
{
+ static gboolean initialized = FALSE;
static gchar *locale_suffixes[3];
static gint n_locale_suffixes = 0;
-
gint i, j;
- static gboolean initialized = FALSE;
if (!initialized)
{
}
}
- i = 0;
- while (gtk_rc_default_files[i] != NULL)
+ g_object_freeze_notify (G_OBJECT (gtk_settings_get_global ()));
+ for (i = 0; gtk_rc_default_files[i] != NULL; i++)
{
- /* Try to find a locale specific RC file corresponding to
- * to parse before the default file.
+ /* Try to find a locale specific RC file corresponding to the
+ * current locale to parse before the default file.
*/
- for (j=n_locale_suffixes-1; j>=0; j--)
+ for (j = n_locale_suffixes - 1; j >= 0; j--)
{
gchar *name = g_strconcat (gtk_rc_default_files[i],
".",
gtk_rc_parse (name);
g_free (name);
}
-
gtk_rc_parse (gtk_rc_default_files[i]);
- i++;
}
+ g_object_thaw_notify (G_OBJECT (gtk_settings_get_global ()));
}
void
}
style->xthickness = -1;
style->ythickness = -1;
+ style->rc_properties = NULL;
style->rc_style_lists = NULL;
style->icon_factories = NULL;
object_class->finalize = gtk_rc_style_finalize;
klass->parse = NULL;
- klass->clone = gtk_rc_style_real_clone;
+ klass->create_rc_style = gtk_rc_style_real_create_rc_style;
klass->merge = gtk_rc_style_real_merge;
klass->create_style = gtk_rc_style_real_create_style;
}
-/* Like g_slist_remove, but remove all copies of data */
-static GSList *
-gtk_rc_slist_remove_all (GSList *list,
- gpointer data)
-{
- GSList *tmp;
- GSList *prev;
-
- prev = NULL;
- tmp = list;
-
- while (tmp)
- {
- if (tmp->data == data)
- {
- if (list == tmp)
- list = list->next;
-
- if (prev)
- prev->next = tmp->next;
-
- g_slist_free_1 (tmp);
-
- if (prev)
- tmp = prev->next;
- else
- tmp = list;
- }
- else
- {
- prev = tmp;
- tmp = tmp->next;
- }
- }
-
- return list;
-}
-
static void
gtk_rc_style_finalize (GObject *object)
{
- gint i;
GSList *tmp_list1, *tmp_list2;
GtkRcStyle *rc_style;
+ gint i;
rc_style = GTK_RC_STYLE (object);
if (rc_style->font_desc)
pango_font_description_free (rc_style->font_desc);
- for (i=0 ; i < 5 ; i++)
+ for (i = 0; i < 5; i++)
if (rc_style->bg_pixmap_name[i])
g_free (rc_style->bg_pixmap_name[i]);
GtkRcStyle *other_style = tmp_list2->data;
if (other_style != rc_style)
- other_style->rc_style_lists =
- gtk_rc_slist_remove_all (other_style->rc_style_lists, rc_styles);
-
+ other_style->rc_style_lists = g_slist_remove_all (other_style->rc_style_lists,
+ rc_styles);
tmp_list2 = tmp_list2->next;
}
tmp_list1 = tmp_list1->next;
}
-
g_slist_free (rc_style->rc_style_lists);
+ if (rc_style->rc_properties)
+ {
+ guint i;
+
+ for (i = 0; i < rc_style->rc_properties->n_nodes; i++)
+ {
+ GtkRcProperty *node = g_bsearch_array_get_nth (rc_style->rc_properties, i);
+
+ g_free (node->origin);
+ g_value_unset (&node->value);
+ }
+ g_bsearch_array_destroy (rc_style->rc_properties);
+ rc_style->rc_properties = NULL;
+ }
+
tmp_list1 = rc_style->icon_factories;
while (tmp_list1)
{
tmp_list1 = tmp_list1->next;
}
-
g_slist_free (rc_style->icon_factories);
G_OBJECT_CLASS (parent_class)->finalize (object);
g_return_val_if_fail (GTK_IS_RC_STYLE (orig), NULL);
- style = GTK_RC_STYLE_GET_CLASS (orig)->clone (orig);
+ style = GTK_RC_STYLE_GET_CLASS (orig)->create_rc_style (orig);
GTK_RC_STYLE_GET_CLASS (style)->merge (style, orig);
return style;
}
static GtkRcStyle *
-gtk_rc_style_real_clone (GtkRcStyle *style)
+gtk_rc_style_real_create_rc_style (GtkRcStyle *style)
{
return GTK_RC_STYLE (g_object_new (G_OBJECT_TYPE (style), NULL));
}
+static gint
+gtk_rc_properties_cmp (gconstpointer bsearch_node1,
+ gconstpointer bsearch_node2)
+{
+ const GtkRcProperty *prop1 = bsearch_node1;
+ const GtkRcProperty *prop2 = bsearch_node2;
+ gint cmp;
+
+ cmp = G_BSEARCH_ARRAY_CMP (prop1->type_name, prop2->type_name);
+ if (cmp == 0)
+ cmp = G_BSEARCH_ARRAY_CMP (prop1->property_name, prop2->property_name);
+
+ return cmp;
+}
+
static void
gtk_rc_style_real_merge (GtkRcStyle *dest,
GtkRcStyle *src)
if (!dest->font_desc && src->font_desc)
dest->font_desc = pango_font_description_copy (src->font_desc);
+
+ if (src->rc_properties)
+ {
+ guint i;
+
+ if (!dest->rc_properties)
+ dest->rc_properties = g_bsearch_array_new (sizeof (GtkRcProperty),
+ gtk_rc_properties_cmp,
+ 0);
+ for (i = 0; i < src->rc_properties->n_nodes; i++)
+ {
+ GtkRcProperty *node = g_bsearch_array_get_nth (src->rc_properties, i);
+ GtkRcProperty *prop, key = { 0, 0, NULL, { 0, }, };
+
+ key.type_name = node->type_name;
+ key.property_name = node->property_name;
+ prop = g_bsearch_array_insert (dest->rc_properties, &key, FALSE);
+ if (!prop->origin)
+ {
+ prop->origin = g_strdup (node->origin);
+ g_value_init (&prop->value, G_VALUE_TYPE (&node->value));
+ g_value_copy (&node->value, &prop->value);
+ }
+ }
+ }
}
static GtkStyle *
gtk_rc_sets_class = gtk_rc_add_rc_sets (gtk_rc_sets_class, rc_style, pattern);
}
+GScanner*
+gtk_rc_scanner_new (void)
+{
+ return g_scanner_new (>k_rc_scanner_config);
+}
+
static void
gtk_rc_parse_any (const gchar *input_name,
gint input_fd,
GScanner *scanner;
guint i;
gboolean done;
-
- scanner = g_scanner_new ((GScannerConfig *) >k_rc_scanner_config);
+
+ scanner = gtk_rc_scanner_new ();
if (input_fd >= 0)
{
}
proto_style_class = GTK_RC_STYLE_GET_CLASS (base_style);
- proto_style = proto_style_class->clone (base_style);
+ proto_style = proto_style_class->create_rc_style (base_style);
tmp_styles = rc_styles;
while (tmp_styles)
* Parsing functions *
*********************/
+static guint
+rc_parse_token_or_compound (GScanner *scanner,
+ GString *gstring,
+ GTokenType delimiter)
+{
+ guint token = g_scanner_get_next_token (scanner);
+
+ /* we either scan a single token (skipping comments)
+ * or a compund statement.
+ * compunds are enclosed in (), [] or {} braces, we read
+ * them in via deep recursion.
+ */
+
+ switch (token)
+ {
+ gchar *string;
+ case G_TOKEN_INT:
+ g_string_printfa (gstring, " 0x%lx", scanner->value.v_int);
+ break;
+ case G_TOKEN_FLOAT:
+ g_string_printfa (gstring, " %f", scanner->value.v_float);
+ break;
+ case G_TOKEN_STRING:
+ string = g_strescape (scanner->value.v_string, NULL);
+ g_string_append (gstring, " \"");
+ g_string_append (gstring, string);
+ g_string_append_c (gstring, '"');
+ g_free (string);
+ break;
+ case G_TOKEN_IDENTIFIER:
+ g_string_append_c (gstring, ' ');
+ g_string_append (gstring, scanner->value.v_identifier);
+ break;
+ case G_TOKEN_COMMENT_SINGLE:
+ case G_TOKEN_COMMENT_MULTI:
+ return rc_parse_token_or_compound (scanner, gstring, delimiter);
+ case G_TOKEN_LEFT_PAREN:
+ g_string_append_c (gstring, ' ');
+ g_string_append_c (gstring, token);
+ token = rc_parse_token_or_compound (scanner, gstring, G_TOKEN_RIGHT_PAREN);
+ if (token != G_TOKEN_NONE)
+ return token;
+ break;
+ case G_TOKEN_LEFT_CURLY:
+ g_string_append_c (gstring, ' ');
+ g_string_append_c (gstring, token);
+ token = rc_parse_token_or_compound (scanner, gstring, G_TOKEN_RIGHT_CURLY);
+ if (token != G_TOKEN_NONE)
+ return token;
+ break;
+ case G_TOKEN_LEFT_BRACE:
+ g_string_append_c (gstring, ' ');
+ g_string_append_c (gstring, token);
+ token = rc_parse_token_or_compound (scanner, gstring, G_TOKEN_RIGHT_BRACE);
+ if (token != G_TOKEN_NONE)
+ return token;
+ break;
+ default:
+ if (token >= 256 || token < 1)
+ return delimiter ? delimiter : G_TOKEN_STRING;
+ g_string_append_c (gstring, ' ');
+ g_string_append_c (gstring, token);
+ if (token == delimiter)
+ return G_TOKEN_NONE;
+ break;
+ }
+ if (!delimiter)
+ return G_TOKEN_NONE;
+ else
+ return rc_parse_token_or_compound (scanner, gstring, delimiter);
+}
+
+static guint
+gtk_rc_parse_assignment (GScanner *scanner,
+ GtkRcProperty *prop)
+{
+ gboolean scan_identifier = scanner->config->scan_identifier;
+ gboolean scan_symbols = scanner->config->scan_symbols;
+ gboolean identifier_2_string = scanner->config->identifier_2_string;
+ gboolean char_2_token = scanner->config->char_2_token;
+ gboolean scan_identifier_NULL = scanner->config->scan_identifier_NULL;
+ gboolean numbers_2_int = scanner->config->numbers_2_int;
+ gboolean negate = FALSE;
+ guint token;
+
+ /* check that this is an assignment */
+ if (g_scanner_get_next_token (scanner) != '=')
+ return '=';
+
+ /* adjust scanner mode */
+ scanner->config->scan_identifier = TRUE;
+ scanner->config->scan_symbols = FALSE;
+ scanner->config->identifier_2_string = FALSE;
+ scanner->config->char_2_token = TRUE;
+ scanner->config->scan_identifier_NULL = FALSE;
+ scanner->config->numbers_2_int = TRUE;
+
+ /* record location */
+ prop->origin = g_strdup_printf ("%s:%u", scanner->input_name, scanner->line);
+
+ /* parse optional sign */
+ if (g_scanner_peek_next_token (scanner) == '-')
+ {
+ g_scanner_get_next_token (scanner); /* eat sign */
+ negate = TRUE;
+ }
+
+ /* parse one of LONG, DOUBLE and STRING or, if that fails, create an unparsed compund */
+ token = g_scanner_peek_next_token (scanner);
+ switch (token)
+ {
+ case G_TOKEN_INT:
+ g_scanner_get_next_token (scanner);
+ g_value_init (&prop->value, G_TYPE_LONG);
+ g_value_set_long (&prop->value, negate ? -scanner->value.v_int : scanner->value.v_int);
+ token = G_TOKEN_NONE;
+ break;
+ case G_TOKEN_FLOAT:
+ g_scanner_get_next_token (scanner);
+ g_value_init (&prop->value, G_TYPE_DOUBLE);
+ g_value_set_double (&prop->value, negate ? -scanner->value.v_float : scanner->value.v_float);
+ token = G_TOKEN_NONE;
+ break;
+ case G_TOKEN_STRING:
+ g_scanner_get_next_token (scanner);
+ if (negate)
+ token = G_TOKEN_INT;
+ else
+ {
+ g_value_init (&prop->value, G_TYPE_STRING);
+ g_value_set_string (&prop->value, scanner->value.v_string);
+ token = G_TOKEN_NONE;
+ }
+ break;
+ case G_TOKEN_IDENTIFIER:
+ case G_TOKEN_LEFT_PAREN:
+ case G_TOKEN_LEFT_CURLY:
+ case G_TOKEN_LEFT_BRACE:
+ if (!negate)
+ {
+ GString *gstring = g_string_new ("");
+
+ token = rc_parse_token_or_compound (scanner, gstring, 0);
+ if (token == G_TOKEN_NONE)
+ {
+ g_string_append_c (gstring, ' ');
+ g_value_init (&prop->value, G_TYPE_GSTRING);
+ g_value_set_static_boxed (&prop->value, gstring);
+ }
+ else
+ g_string_free (gstring, TRUE);
+ break;
+ }
+ /* fall through */
+ default:
+ g_scanner_get_next_token (scanner);
+ token = G_TOKEN_INT;
+ break;
+ }
+
+ /* restore scanner mode */
+ scanner->config->scan_identifier = scan_identifier;
+ scanner->config->scan_symbols = scan_symbols;
+ scanner->config->identifier_2_string = identifier_2_string;
+ scanner->config->char_2_token = char_2_token;
+ scanner->config->scan_identifier_NULL = scan_identifier_NULL;
+ scanner->config->numbers_2_int = numbers_2_int;
+
+ return token;
+}
+
+static gboolean
+is_c_identifier (const gchar *string)
+{
+ const gchar *p;
+ gboolean is_varname;
+
+ is_varname = strchr (G_CSET_a_2_z G_CSET_A_2_Z "_", string[0]) != NULL;
+ for (p = string + 1; *p && is_varname; p++)
+ is_varname &= strchr (G_CSET_a_2_z G_CSET_A_2_Z G_CSET_DIGITS "_-", *p) != NULL;
+
+ return is_varname;
+}
+
static guint
gtk_rc_parse_statement (GScanner *scanner)
{
guint token;
token = g_scanner_peek_next_token (scanner);
-
switch (token)
{
case GTK_RC_TOKEN_INCLUDE:
token = g_scanner_get_next_token (scanner);
if (token != GTK_RC_TOKEN_INCLUDE)
return GTK_RC_TOKEN_INCLUDE;
-
token = g_scanner_get_next_token (scanner);
if (token != G_TOKEN_STRING)
return G_TOKEN_STRING;
-
gtk_rc_parse_file (scanner->value.v_string, FALSE);
return G_TOKEN_NONE;
case GTK_RC_TOKEN_IM_MODULE_FILE:
return gtk_rc_parse_im_module_file (scanner);
+ case G_TOKEN_IDENTIFIER:
+ if (is_c_identifier (scanner->next_value.v_identifier))
+ {
+ GtkRcProperty prop = { 0, 0, NULL, { 0, }, };
+ gchar *name;
+
+ g_scanner_get_next_token (scanner); /* eat identifier */
+ name = g_strdup (scanner->value.v_identifier);
+
+ token = gtk_rc_parse_assignment (scanner, &prop);
+ if (token == G_TOKEN_NONE)
+ {
+ GtkSettingsValue svalue;
+
+ svalue.origin = prop.origin;
+ memcpy (&svalue.value, &prop.value, sizeof (prop.value));
+ g_strcanon (name, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-');
+ gtk_settings_set_property_value (gtk_settings_get_global (),
+ name,
+ &svalue);
+ }
+ g_free (prop.origin);
+ if (G_VALUE_TYPE (&prop.value))
+ g_value_unset (&prop.value);
+ g_free (name);
+
+ return token;
+ }
+ else
+ {
+ g_scanner_get_next_token (scanner);
+ return G_TOKEN_IDENTIFIER;
+ }
default:
g_scanner_get_next_token (scanner);
return /* G_TOKEN_SYMBOL */ GTK_RC_TOKEN_STYLE;
pango_font_description_free (rc_style->font_desc);
rc_style->font_desc = pango_font_description_copy (parent_style->font_desc);
}
+
+ if (parent_style->rc_properties)
+ {
+ guint i;
+
+ if (!rc_style->rc_properties)
+ rc_style->rc_properties = g_bsearch_array_new (sizeof (GtkRcProperty),
+ gtk_rc_properties_cmp,
+ 0);
+ for (i = 0; i < parent_style->rc_properties->n_nodes; i++)
+ {
+ GtkRcProperty *node = g_bsearch_array_get_nth (parent_style->rc_properties, i);
+ GtkRcProperty *prop, key = { 0, 0, NULL, { 0, }, };
+
+ key.type_name = node->type_name;
+ key.property_name = node->property_name;
+ prop = g_bsearch_array_insert (rc_style->rc_properties, &key, FALSE);
+ if (prop->origin)
+ {
+ g_free (prop->origin);
+ g_value_unset (&prop->value);
+ }
+ prop->origin = g_strdup (node->origin);
+ g_value_init (&prop->value, G_VALUE_TYPE (&node->value));
+ g_value_copy (&node->value, &prop->value);
+ }
+ }
for (i = 0; i < 5; i++)
{
}
token = gtk_rc_parse_stock (scanner, rc_style, our_factory);
break;
+ case G_TOKEN_IDENTIFIER:
+ if (is_c_identifier (scanner->next_value.v_identifier) &&
+ scanner->next_value.v_identifier[0] >= 'A' &&
+ scanner->next_value.v_identifier[0] <= 'Z') /* match namespaced type names */
+ {
+ GtkRcProperty prop = { 0, 0, NULL, { 0, }, };
+
+ g_scanner_get_next_token (scanner); /* eat type name */
+ prop.type_name = g_quark_from_string (scanner->value.v_identifier);
+ if (g_scanner_get_next_token (scanner) != ':' ||
+ g_scanner_get_next_token (scanner) != ':')
+ {
+ token = ':';
+ break;
+ }
+ if (g_scanner_get_next_token (scanner) != G_TOKEN_IDENTIFIER ||
+ !is_c_identifier (scanner->value.v_identifier))
+ {
+ token = G_TOKEN_IDENTIFIER;
+ break;
+ }
+
+ /* it's important that we do the same canonification as GParamSpecPool here */
+ g_strcanon (scanner->value.v_identifier, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-');
+ prop.property_name = g_quark_from_string (scanner->value.v_identifier);
+
+ token = gtk_rc_parse_assignment (scanner, &prop);
+ if (token == G_TOKEN_NONE)
+ {
+ GtkRcProperty *tmp;
+
+ g_return_val_if_fail (prop.origin != NULL && G_VALUE_TYPE (&prop.value) != 0, G_TOKEN_ERROR);
+
+ if (!rc_style->rc_properties)
+ rc_style->rc_properties = g_bsearch_array_new (sizeof (GtkRcProperty),
+ gtk_rc_properties_cmp,
+ 0);
+ tmp = g_bsearch_array_insert (rc_style->rc_properties, &prop, FALSE);
+ if (prop.origin != tmp->origin)
+ {
+ g_free (tmp->origin);
+ g_value_unset (&tmp->value);
+ tmp->origin = prop.origin;
+ memcpy (&tmp->value, &prop.value, sizeof (prop.value));
+ }
+ }
+ else
+ {
+ g_free (prop.origin);
+ if (G_VALUE_TYPE (&prop.value))
+ g_value_unset (&prop.value);
+ }
+ }
+ else
+ {
+ g_scanner_get_next_token (scanner);
+ token = G_TOKEN_IDENTIFIER;
+ }
+ break;
default:
g_scanner_get_next_token (scanner);
token = G_TOKEN_RIGHT_CURLY;
if (token != G_TOKEN_NONE)
{
if (insert)
- {
- if (rc_style->font_desc)
- pango_font_description_free (rc_style->font_desc);
-
- for (i = 0; i < 5; i++)
- if (rc_style->bg_pixmap_name[i])
- g_free (rc_style->bg_pixmap_name[i]);
- g_free (rc_style);
- }
+ gtk_rc_style_unref (rc_style);
+
return token;
}
token = g_scanner_peek_next_token (scanner);
- }
+ } /* while (token != G_TOKEN_RIGHT_CURLY) */
token = g_scanner_get_next_token (scanner);
if (token != G_TOKEN_RIGHT_CURLY)
return G_TOKEN_NONE;
}
+const GtkRcProperty*
+_gtk_rc_style_lookup_rc_property (GtkRcStyle *rc_style,
+ GQuark type_name,
+ GQuark property_name)
+{
+ GtkRcProperty *node = NULL;
+
+ g_return_val_if_fail (GTK_IS_RC_STYLE (rc_style), NULL);
+
+ if (rc_style->rc_properties)
+ {
+ GtkRcProperty key;
+
+ key.type_name = type_name;
+ key.property_name = property_name;
+
+ node = g_bsearch_array_lookup (rc_style->rc_properties, &key);
+ }
+
+ return node;
+}
+
static guint
gtk_rc_parse_bg (GScanner *scanner,
GtkRcStyle *style)
g_return_val_if_fail (scanner != NULL, G_TOKEN_ERROR);
- /* we don't need to set our own scop here, because
+ /* we don't need to set our own scope here, because
* we don't need own symbols
*/
gint ythickness;
/*< private >*/
+ GBSearchArray *rc_properties;
/* list of RC style lists including this RC style */
GSList *rc_style_lists;
* g_object_new (G_OBJECT_TYPE (style), NULL);
* should work in most cases.
*/
- GtkRcStyle * (*clone) (GtkRcStyle *rc_style);
+ GtkRcStyle * (*create_rc_style) (GtkRcStyle *rc_style);
/* Fill in engine specific parts of GtkRcStyle by parsing contents
* of brackets. Returns G_TOKEN_NONE if succesful, otherwise returns
};
void gtk_rc_init (void);
-void gtk_rc_add_default_file (const gchar *filename);
+void gtk_rc_add_default_file (const gchar *filename);
void gtk_rc_set_default_files (gchar **filenames);
gchar** gtk_rc_get_default_files (void);
void gtk_rc_parse (const gchar *filename);
GType gtk_rc_style_get_type (void) G_GNUC_CONST;
GtkRcStyle* gtk_rc_style_new (void);
-GtkRcStyle *gtk_rc_style_copy (GtkRcStyle *orig);
+GtkRcStyle* gtk_rc_style_copy (GtkRcStyle *orig);
void gtk_rc_style_ref (GtkRcStyle *rc_style);
void gtk_rc_style_unref (GtkRcStyle *rc_style);
GTK_RC_TOKEN_LAST
} GtkRcTokenType;
-guint gtk_rc_parse_color (GScanner *scanner,
+GScanner* gtk_rc_scanner_new (void);
+guint gtk_rc_parse_color (GScanner *scanner,
GdkColor *color);
-guint gtk_rc_parse_state (GScanner *scanner,
+guint gtk_rc_parse_state (GScanner *scanner,
GtkStateType *state);
-guint gtk_rc_parse_priority (GScanner *scanner,
+guint gtk_rc_parse_priority (GScanner *scanner,
GtkPathPriorityType *priority);
-
-#ifdef G_OS_WIN32
-gchar *gtk_win32_get_installation_directory (void);
+/* rc properties
+ * (structure forward declared in gtkstyle.h)
+ */
+struct _GtkRcProperty
+{
+ /* quark-ified property identifier like "GtkScrollbar::spacing" */
+ GQuark type_name;
+ GQuark property_name;
+
+ /* fields similar to GtkSettingsValue */
+ gchar *origin;
+ GValue value;
+};
+const GtkRcProperty* _gtk_rc_style_lookup_rc_property (GtkRcStyle *rc_style,
+ GQuark type_name,
+ GQuark property_name);
+
+
+#ifdef G_OS_WIN32
+gchar* gtk_win32_get_installation_directory (void);
#endif
--- /dev/null
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2000 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#include "gtksettings.h"
+
+
+
+enum {
+ PROP_0,
+ PROP_DOUBLE_CLICK_TIMEOUT,
+ PROP_BELL_PITCH,
+ PROP_BELL_DURATION,
+ PROP_BELL_PERCENT
+};
+
+
+/* --- prototypes --- */
+static void gtk_settings_init (GtkSettings *settings);
+static void gtk_settings_class_init (GtkSettingsClass *class);
+static void gtk_settings_finalize (GObject *object);
+static GObject* gtk_settings_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties);
+static void gtk_settings_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gtk_settings_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gtk_settings_notify (GObject *object,
+ GParamSpec *pspec);
+static guint settings_install_property_parser (GtkSettingsClass *class,
+ GParamSpec *pspec,
+ GtkRcPropertyParser parser);
+
+
+/* --- variables --- */
+static gpointer parent_class = NULL;
+static GtkSettings *the_singleton = NULL;
+static GQuark quark_property_parser = 0;
+static GQuark quark_property_id = 0;
+static GSList *object_list = NULL;
+static guint class_n_properties = 0;
+
+
+/* --- functions --- */
+GType
+gtk_settings_get_type (void)
+{
+ static GType settings_type = 0;
+
+ if (!settings_type)
+ {
+ static const GTypeInfo settings_info =
+ {
+ sizeof (GtkSettingsClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) gtk_settings_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GtkSettings),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gtk_settings_init,
+ };
+
+ settings_type = g_type_register_static (G_TYPE_OBJECT, "GtkSettings", &settings_info, 0);
+ }
+
+ return settings_type;
+}
+
+static void
+gtk_settings_init (GtkSettings *settings)
+{
+ GObjectClass *gobject_class = G_OBJECT_GET_CLASS (settings);
+ guint i;
+
+ g_datalist_init (&settings->queued_settings);
+ settings->property_values = NULL;
+ object_list = g_slist_prepend (object_list, settings);
+
+ /* build up property array for all yet existing properties and queue
+ * notification for them (at least notification for internal properties
+ * will instantly be caught)
+ */
+ settings->property_values = g_renew (GValue, settings->property_values, class_n_properties);
+ settings->property_values[class_n_properties - 1].g_type = 0;
+ for (i = 0; i < class_n_properties; i++)
+ {
+ GParamSpec *pspec = gobject_class->property_specs[i]; // FIXME: g_object_list_properties(this_class_type)
+
+ g_value_init (settings->property_values + i, G_PARAM_SPEC_VALUE_TYPE (pspec));
+ g_param_value_set_default (pspec, settings->property_values + i);
+ g_object_notify (G_OBJECT (settings), pspec->name);
+ }
+}
+
+static void
+gtk_settings_class_init (GtkSettingsClass *class)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+
+ parent_class = g_type_class_peek_parent (class);
+
+ gobject_class->constructor = gtk_settings_constructor;
+ gobject_class->finalize = gtk_settings_finalize;
+ gobject_class->get_property = gtk_settings_get_property;
+ gobject_class->set_property = gtk_settings_set_property;
+ gobject_class->notify = gtk_settings_notify;
+
+ quark_property_parser = g_quark_from_static_string ("gtk-rc-property-parser");
+ quark_property_id = g_quark_try_string ("GObject-property-id");
+ g_assert (quark_property_id != 0); /* special quarks from GObjectClass */
+
+ g_assert (PROP_DOUBLE_CLICK_TIMEOUT ==
+ settings_install_property_parser (class,
+ g_param_spec_int ("double-click-timeout", "Double Click Timeout", NULL,
+ 1, G_MAXINT, 1,
+ G_PARAM_READWRITE),
+ NULL));
+ g_assert (PROP_BELL_PITCH ==
+ settings_install_property_parser (class,
+ g_param_spec_int ("bell-pitch", "Bell Pitch", NULL,
+ 0, G_MAXINT, 440,
+ G_PARAM_READWRITE),
+ NULL));
+ g_assert (PROP_BELL_DURATION ==
+ settings_install_property_parser (class,
+ g_param_spec_int ("bell_duration", "Bell Duration", NULL,
+ 1, G_MAXINT, 250,
+ G_PARAM_READWRITE),
+ NULL));
+ g_assert (PROP_BELL_PERCENT ==
+ settings_install_property_parser (class,
+ g_param_spec_float ("bell_percent", "Bell Percent", NULL,
+ 0, 100, 80,
+ G_PARAM_READWRITE),
+ NULL));
+}
+
+static void
+gtk_settings_finalize (GObject *object)
+{
+ GtkSettings *settings = GTK_SETTINGS (object);
+ guint i;
+
+ object_list = g_slist_remove (object_list, settings);
+
+ for (i = 0; i < class_n_properties; i++)
+ g_value_unset (settings->property_values + i);
+ g_free (settings->property_values);
+
+ g_datalist_clear (&settings->queued_settings);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static GObject*
+gtk_settings_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
+{
+ GObject *object;
+
+ /* currently we're a singleton, that might change with multiple display support though */
+ if (!the_singleton)
+ {
+ object = G_OBJECT_CLASS (parent_class)->constructor (type,
+ n_construct_properties,
+ construct_properties);
+ the_singleton = GTK_SETTINGS (g_object_ref (object));
+ }
+ else
+ object = g_object_ref (G_OBJECT (the_singleton));
+
+ return object;
+}
+
+GtkSettings*
+gtk_settings_get_global (void)
+{
+ if (!the_singleton)
+ g_object_new (GTK_TYPE_SETTINGS, NULL);
+
+ return the_singleton; /* we don't add a reference count here, we'd be settings_ref_global() if we did */
+}
+
+static void
+gtk_settings_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GtkSettings *settings = GTK_SETTINGS (object);
+
+ g_value_copy (value, settings->property_values + property_id - 1);
+}
+
+static void
+gtk_settings_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GtkSettings *settings = GTK_SETTINGS (object);
+
+ g_value_copy (settings->property_values + property_id - 1, value);
+}
+
+static void
+gtk_settings_notify (GObject *object,
+ GParamSpec *pspec)
+{
+ guint property_id = GPOINTER_TO_UINT (g_param_spec_get_qdata ((pspec), quark_property_id));
+
+#if 1
+ GValue tmp_value = { 0, };
+ gchar *contents;
+ g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
+ g_object_get_property (object, pspec->name, &tmp_value);
+ contents = g_strdup_value_contents (&tmp_value);
+#endif
+
+ switch (property_id)
+ {
+ case PROP_DOUBLE_CLICK_TIMEOUT:
+ g_print ("settings-notify: %s = \"%s\"\n", pspec->name, contents);
+ break;
+ case PROP_BELL_PITCH:
+ g_print ("settings-notify: %s = \"%s\"\n", pspec->name, contents);
+ break;
+ case PROP_BELL_DURATION:
+ g_print ("settings-notify: %s = \"%s\"\n", pspec->name, contents);
+ break;
+ case PROP_BELL_PERCENT:
+ g_print ("settings-notify: %s = \"%s\"\n", pspec->name, contents);
+ break;
+ }
+
+#if 1
+ g_free (contents);
+ g_value_unset (&tmp_value);
+#endif
+}
+
+static void
+apply_queued_setting (GtkSettings *data,
+ GParamSpec *pspec,
+ GtkSettingsValue *qvalue)
+{
+ gboolean warn_convert = TRUE;
+
+ if (g_value_type_transformable (G_VALUE_TYPE (&qvalue->value), G_PARAM_SPEC_VALUE_TYPE (pspec)))
+ {
+ GValue tmp_value = { 0, };
+
+ warn_convert = FALSE;
+ g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
+ if (g_param_value_convert (pspec, &qvalue->value, &tmp_value, TRUE))
+ g_object_set_property (G_OBJECT (data), pspec->name, &tmp_value);
+ else
+ {
+ gchar *debug = g_strdup_value_contents (&tmp_value);
+
+ g_message ("%s: rc-value `%s' for rc-property \"%s\" of type `%s' has invalid contents \"%s\"",
+ qvalue->origin,
+ G_VALUE_TYPE_NAME (&qvalue->value),
+ pspec->name,
+ g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
+ debug);
+ g_free (debug);
+ }
+ g_value_unset (&tmp_value);
+ }
+ else
+ {
+ GtkRcPropertyParser parser = g_param_spec_get_qdata (pspec, quark_property_parser);
+
+ if (parser)
+ {
+ GValue tmp_value = { 0, };
+
+ g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
+ if (parser (pspec, g_value_get_boxed (&qvalue->value), &tmp_value))
+ {
+ warn_convert = FALSE;
+ g_object_set_property (G_OBJECT (data), pspec->name, &tmp_value);
+ }
+ g_value_unset (&tmp_value);
+ }
+ }
+
+ if (warn_convert)
+ g_message ("%s: unable to convert rc-value of type `%s' to rc-property \"%s\" of type `%s'",
+ qvalue->origin,
+ G_VALUE_TYPE_NAME (&qvalue->value),
+ pspec->name,
+ g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)));
+}
+
+static guint
+settings_install_property_parser (GtkSettingsClass *class,
+ GParamSpec *pspec,
+ GtkRcPropertyParser parser)
+{
+ GSList *node, *next;
+
+ switch (G_TYPE_FUNDAMENTAL (G_PARAM_SPEC_VALUE_TYPE (pspec)))
+ {
+ case G_TYPE_BOOLEAN:
+ case G_TYPE_UCHAR:
+ case G_TYPE_CHAR:
+ case G_TYPE_UINT:
+ case G_TYPE_INT:
+ case G_TYPE_ULONG:
+ case G_TYPE_LONG:
+ case G_TYPE_FLOAT:
+ case G_TYPE_DOUBLE:
+ case G_TYPE_STRING:
+ break;
+ default:
+ if (!parser)
+ g_warning (G_STRLOC ": parser needs to be specified for property \"%s\" of type `%s'",
+ pspec->name, g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)));
+ return 0;
+ }
+ if (g_object_class_find_property (G_OBJECT_CLASS (class), pspec->name))
+ {
+ g_warning (G_STRLOC ": an rc-data property \"%s\" already exists",
+ pspec->name);
+ return 0;
+ }
+
+ for (node = object_list; node; node = node->next)
+ g_object_freeze_notify (node->data);
+
+ g_object_class_install_property (G_OBJECT_CLASS (class), ++class_n_properties, pspec);
+ g_param_spec_set_qdata (pspec, quark_property_parser, parser);
+
+ for (node = object_list; node; node = node->next)
+ {
+ GtkSettings *settings = node->data;
+ GtkSettingsValue *qvalue;
+
+ settings->property_values = g_renew (GValue, settings->property_values, class_n_properties);
+ settings->property_values[class_n_properties - 1].g_type = 0;
+ g_value_init (settings->property_values + class_n_properties - 1, G_PARAM_SPEC_VALUE_TYPE (pspec));
+ g_param_value_set_default (pspec, settings->property_values + class_n_properties - 1);
+ g_object_notify (G_OBJECT (settings), pspec->name);
+
+ qvalue = g_datalist_get_data (&settings->queued_settings, pspec->name);
+ if (qvalue)
+ apply_queued_setting (settings, pspec, qvalue);
+ }
+
+ for (node = object_list; node; node = next)
+ {
+ next = node->next;
+ g_object_thaw_notify (node->data);
+ }
+
+ return class_n_properties;
+}
+
+void
+gtk_settings_install_property (GtkSettings *settings,
+ GParamSpec *pspec)
+{
+ g_return_if_fail (GTK_IS_SETTINGS (settings));
+ g_return_if_fail (G_IS_PARAM_SPEC (pspec));
+
+ settings_install_property_parser (GTK_SETTINGS_GET_CLASS (settings), pspec, NULL);
+}
+
+void
+gtk_settings_install_property_parser (GtkSettings *settings,
+ GParamSpec *pspec,
+ GtkRcPropertyParser parser)
+{
+ g_return_if_fail (GTK_IS_SETTINGS (settings));
+ g_return_if_fail (G_IS_PARAM_SPEC (pspec));
+ g_return_if_fail (parser != NULL);
+
+ settings_install_property_parser (GTK_SETTINGS_GET_CLASS (settings), pspec, parser);
+}
+
+static void
+free_value (gpointer data)
+{
+ GtkSettingsValue *qvalue = data;
+
+ g_value_unset (&qvalue->value);
+ g_free (qvalue->origin);
+ g_free (qvalue);
+}
+
+void
+gtk_settings_set_property_value (GtkSettings *settings,
+ const gchar *prop_name,
+ const GtkSettingsValue *new_value)
+{
+ GtkSettingsValue *qvalue;
+ GParamSpec *pspec;
+ gchar *name;
+ GQuark name_quark;
+
+ g_return_if_fail (GTK_SETTINGS (settings));
+ g_return_if_fail (prop_name != NULL);
+ g_return_if_fail (new_value != NULL);
+ g_return_if_fail (new_value->origin != NULL);
+
+ if (!G_VALUE_HOLDS_LONG (&new_value->value) &&
+ !G_VALUE_HOLDS_DOUBLE (&new_value->value) &&
+ !G_VALUE_HOLDS_STRING (&new_value->value) &&
+ !G_VALUE_HOLDS (&new_value->value, G_TYPE_GSTRING))
+ {
+ g_warning (G_STRLOC ": value type invalid");
+ return;
+ }
+
+ name = g_strdup (prop_name);
+ g_strcanon (name, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-');
+ name_quark = g_quark_try_string (name);
+ if (name_quark)
+ g_free (name);
+ else
+ name_quark = g_quark_from_string (name);
+
+ qvalue = g_datalist_id_get_data (&settings->queued_settings, name_quark);
+ if (!qvalue)
+ {
+ qvalue = g_new0 (GtkSettingsValue, 1);
+ g_datalist_id_set_data_full (&settings->queued_settings, name_quark, qvalue, free_value);
+ }
+ else
+ {
+ g_free (qvalue->origin);
+ g_value_unset (&qvalue->value);
+ }
+ qvalue->origin = g_strdup (new_value->origin);
+ g_value_init (&qvalue->value, G_VALUE_TYPE (&new_value->value));
+ g_value_copy (&new_value->value, &qvalue->value);
+ pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (settings), g_quark_to_string (name_quark));
+ if (pspec)
+ apply_queued_setting (settings, pspec, qvalue);
+}
+
+void
+gtk_settings_set_string_property (GtkSettings *settings,
+ const gchar *name,
+ const gchar *v_string,
+ const gchar *origin)
+{
+ GtkSettingsValue svalue = { NULL, { 0, }, };
+
+ g_return_if_fail (GTK_SETTINGS (settings));
+ g_return_if_fail (name != NULL);
+ g_return_if_fail (v_string != NULL);
+ g_return_if_fail (origin != NULL);
+
+ svalue.origin = (gchar*) origin;
+ g_value_init (&svalue.value, G_TYPE_STRING);
+ g_value_set_static_string (&svalue.value, v_string);
+ gtk_settings_set_property_value (settings, name, &svalue);
+ g_value_unset (&svalue.value);
+}
+
+void
+gtk_settings_set_long_property (GtkSettings *settings,
+ const gchar *name,
+ glong v_long,
+ const gchar *origin)
+{
+ GtkSettingsValue svalue = { NULL, { 0, }, };
+
+ g_return_if_fail (GTK_SETTINGS (settings));
+ g_return_if_fail (name != NULL);
+ g_return_if_fail (origin != NULL);
+
+ svalue.origin = (gchar*) origin;
+ g_value_init (&svalue.value, G_TYPE_LONG);
+ g_value_set_long (&svalue.value, v_long);
+ gtk_settings_set_property_value (settings, name, &svalue);
+ g_value_unset (&svalue.value);
+}
+
+void
+gtk_settings_set_double_property (GtkSettings *settings,
+ const gchar *name,
+ gdouble v_double,
+ const gchar *origin)
+{
+ GtkSettingsValue svalue = { NULL, { 0, }, };
+
+ g_return_if_fail (GTK_SETTINGS (settings));
+ g_return_if_fail (name != NULL);
+ g_return_if_fail (origin != NULL);
+
+ svalue.origin = (gchar*) origin;
+ g_value_init (&svalue.value, G_TYPE_DOUBLE);
+ g_value_set_double (&svalue.value, v_double);
+ gtk_settings_set_property_value (settings, name, &svalue);
+ g_value_unset (&svalue.value);
+}
+
+gboolean
+gtk_rc_property_parse_color (const GParamSpec *pspec,
+ const GString *gstring,
+ GValue *property_value)
+{
+ GdkColor color = { 0, 0, 0, 0, };
+ GScanner *scanner;
+ gboolean success;
+
+ g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
+ g_return_val_if_fail (G_VALUE_HOLDS (property_value, GTK_TYPE_GDK_COLOR), FALSE);
+
+ scanner = gtk_rc_scanner_new ();
+ g_scanner_input_text (scanner, gstring->str, gstring->len);
+ if (gtk_rc_parse_color (scanner, &color) == G_TOKEN_NONE &&
+ g_scanner_get_next_token (scanner) == G_TOKEN_EOF)
+ {
+ g_value_set_boxed (property_value, &color);
+ success = TRUE;
+ }
+ else
+ success = FALSE;
+ g_scanner_destroy (scanner);
+
+ return success;
+}
+
+gboolean
+gtk_rc_property_parse_enum (const GParamSpec *pspec,
+ const GString *gstring,
+ GValue *property_value)
+{
+ gboolean need_closing_brace = FALSE, success = FALSE;
+ GScanner *scanner;
+ GEnumValue *enum_value = NULL;
+
+ g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
+ g_return_val_if_fail (G_VALUE_HOLDS_ENUM (property_value), FALSE);
+
+ scanner = gtk_rc_scanner_new ();
+ g_scanner_input_text (scanner, gstring->str, gstring->len);
+
+ /* we just want to parse _one_ value, but for consistency with flags parsing
+ * we support optional paranthesis
+ */
+ g_scanner_get_next_token (scanner);
+ if (scanner->token == '(')
+ {
+ need_closing_brace = TRUE;
+ g_scanner_get_next_token (scanner);
+ }
+ if (scanner->token == G_TOKEN_IDENTIFIER)
+ {
+ GEnumClass *class = G_PARAM_SPEC_ENUM (pspec)->enum_class;
+
+ enum_value = g_enum_get_value_by_name (class, scanner->value.v_identifier);
+ if (!enum_value)
+ enum_value = g_enum_get_value_by_nick (class, scanner->value.v_identifier);
+ if (enum_value)
+ {
+ g_value_set_enum (property_value, enum_value->value);
+ success = TRUE;
+ }
+ }
+ else if (scanner->token == G_TOKEN_INT)
+ {
+ g_value_set_enum (property_value, scanner->value.v_int);
+ success = TRUE;
+ }
+ if (need_closing_brace && g_scanner_get_next_token (scanner) != ')')
+ success = FALSE;
+ if (g_scanner_get_next_token (scanner) != G_TOKEN_EOF)
+ success = FALSE;
+
+ g_scanner_destroy (scanner);
+
+ return success;
+}
+
+static guint
+parse_flags_value (GScanner *scanner,
+ GFlagsClass *class,
+ guint *number)
+{
+ g_scanner_get_next_token (scanner);
+ if (scanner->token == G_TOKEN_IDENTIFIER)
+ {
+ GFlagsValue *flags_value;
+
+ flags_value = g_flags_get_value_by_name (class, scanner->value.v_identifier);
+ if (!flags_value)
+ flags_value = g_flags_get_value_by_nick (class, scanner->value.v_identifier);
+ if (flags_value)
+ {
+ *number |= flags_value->value;
+ return G_TOKEN_NONE;
+ }
+ }
+ else if (scanner->token == G_TOKEN_INT)
+ {
+ *number |= scanner->value.v_int;
+ return G_TOKEN_NONE;
+ }
+ return G_TOKEN_IDENTIFIER;
+}
+
+gboolean
+gtk_rc_property_parse_flags (const GParamSpec *pspec,
+ const GString *gstring,
+ GValue *property_value)
+{
+ GFlagsClass *class;
+ gboolean success = FALSE;
+ GScanner *scanner;
+
+ g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
+ g_return_val_if_fail (G_VALUE_HOLDS_FLAGS (property_value), FALSE);
+
+ class = G_PARAM_SPEC_FLAGS (pspec)->flags_class;
+ scanner = gtk_rc_scanner_new ();
+ g_scanner_input_text (scanner, gstring->str, gstring->len);
+
+ /* parse either a single flags value or a "\( ... [ \| ... ] \)" compound */
+ if (g_scanner_peek_next_token (scanner) == G_TOKEN_IDENTIFIER ||
+ scanner->next_token == G_TOKEN_INT)
+ {
+ guint token, flags_value = 0;
+
+ token = parse_flags_value (scanner, class, &flags_value);
+
+ if (token == G_TOKEN_NONE && g_scanner_peek_next_token (scanner) == G_TOKEN_EOF)
+ {
+ success = TRUE;
+ g_value_set_flags (property_value, flags_value);
+ }
+
+ }
+ else if (g_scanner_get_next_token (scanner) == '(')
+ {
+ guint token, flags_value = 0;
+
+ /* parse first value */
+ token = parse_flags_value (scanner, class, &flags_value);
+
+ /* parse nth values, preceeded by '|' */
+ while (token == G_TOKEN_NONE && g_scanner_get_next_token (scanner) == '|')
+ token = parse_flags_value (scanner, class, &flags_value);
+
+ /* done, last token must have closed expression */
+ if (token == G_TOKEN_NONE && scanner->token == ')' &&
+ g_scanner_peek_next_token (scanner) == G_TOKEN_EOF)
+ {
+ g_value_set_flags (property_value, flags_value);
+ success = TRUE;
+ }
+ }
+ g_scanner_destroy (scanner);
+
+ return success;
+}
--- /dev/null
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2000 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#ifndef __GTK_SETTINGS_H__
+#define __GTK_SETTINGS_H__
+
+#include <gtk/gtkrc.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/* -- type macros --- */
+#define GTK_TYPE_SETTINGS (gtk_settings_get_type ())
+#define GTK_SETTINGS(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_SETTINGS, GtkSettings))
+#define GTK_SETTINGS_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_SETTINGS, GtkSettingsClass))
+#define GTK_IS_SETTINGS(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_SETTINGS))
+#define GTK_IS_SETTINGS_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_SETTINGS))
+#define GTK_SETTINGS_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_SETTINGS, GtkSettingsClass))
+
+
+/* --- typedefs --- */
+typedef struct _GtkSettings GtkSettings;
+typedef struct _GtkSettingsClass GtkSettingsClass;
+typedef struct _GtkSettingsValue GtkSettingsValue;
+
+
+/* --- structures --- */
+struct _GtkSettings
+{
+ GObject parent_instance;
+
+ GData *queued_settings; /* of type GtkSettingsValue* */
+ GValue *property_values;
+};
+struct _GtkSettingsClass
+{
+ GObjectClass parent_class;
+
+};
+struct _GtkSettingsValue
+{
+ /* origin should be something like "filename:linenumber" for rc files,
+ * or e.g. "XProperty" for other sources
+ */
+ gchar *origin;
+
+ /* valid types are LONG, DOUBLE and STRING corresponding to the token parsed,
+ * or a GSTRING holding an unparsed statement
+ */
+ GValue value;
+};
+
+
+/* --- functions --- */
+GType gtk_settings_get_type (void);
+GtkSettings* gtk_settings_get_global (void); /* singleton */
+void gtk_settings_install_property (GtkSettings *settings,
+ GParamSpec *pspec);
+void gtk_settings_install_property_parser (GtkSettings *settings,
+ GParamSpec *pspec,
+ GtkRcPropertyParser parser);
+
+/* --- precoded parsing functions --- */
+gboolean gtk_rc_property_parse_color (const GParamSpec *pspec,
+ const GString *gstring,
+ GValue *property_value);
+gboolean gtk_rc_property_parse_enum (const GParamSpec *pspec,
+ const GString *gstring,
+ GValue *property_value);
+gboolean gtk_rc_property_parse_flags (const GParamSpec *pspec,
+ const GString *gstring,
+ GValue *property_value);
+
+/*< private >*/
+void gtk_settings_set_property_value (GtkSettings *settings,
+ const gchar *name,
+ const GtkSettingsValue *svalue);
+void gtk_settings_set_string_property (GtkSettings *settings,
+ const gchar *name,
+ const gchar *v_string,
+ const gchar *origin);
+void gtk_settings_set_long_property (GtkSettings *settings,
+ const gchar *name,
+ glong v_long,
+ const gchar *origin);
+void gtk_settings_set_double_property (GtkSettings *settings,
+ const gchar *name,
+ gdouble v_double,
+ const gchar *origin);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __GTK_SETTINGS_H__ */
#include "gtkspinbutton.h"
#include "gtkmain.h"
#include "gtksignal.h"
+#include "gtksettings.h"
#define MIN_SPIN_BUTTON_WIDTH 30
ARG_NUMERIC,
ARG_WRAP,
ARG_UPDATE_POLICY,
- ARG_SHADOW_TYPE,
ARG_VALUE
};
static gint gtk_spin_button_default_input (GtkSpinButton *spin_button,
gfloat *new_val);
static gint gtk_spin_button_default_output (GtkSpinButton *spin_button);
+static gint spin_button_get_shadow_type (GtkSpinButton *spin_button);
static GtkEntryClass *parent_class = NULL;
GTK_TYPE_SPIN_BUTTON_UPDATE_POLICY,
GTK_ARG_READWRITE,
ARG_UPDATE_POLICY);
- gtk_object_add_arg_type ("GtkSpinButton::shadow_type",
- GTK_TYPE_SHADOW_TYPE,
- GTK_ARG_READWRITE,
- ARG_SHADOW_TYPE);
gtk_object_add_arg_type ("GtkSpinButton::value",
GTK_TYPE_FLOAT,
GTK_ARG_READWRITE,
ARG_VALUE);
-
+
+ gtk_widget_class_install_style_property_parser (widget_class,
+ g_param_spec_enum ("shadow_type", "Shadow Type", NULL,
+ GTK_TYPE_SHADOW_TYPE,
+ GTK_SHADOW_NONE,
+ G_PARAM_READABLE),
+ gtk_rc_property_parse_enum);
spinbutton_signals[INPUT] =
gtk_signal_new ("input",
GTK_RUN_LAST,
case ARG_UPDATE_POLICY:
gtk_spin_button_set_update_policy (spin_button, GTK_VALUE_ENUM (*arg));
break;
- case ARG_SHADOW_TYPE:
- gtk_spin_button_set_shadow_type (spin_button, GTK_VALUE_ENUM (*arg));
- break;
case ARG_VALUE:
gtk_spin_button_set_value (spin_button, GTK_VALUE_FLOAT (*arg));
break;
case ARG_UPDATE_POLICY:
GTK_VALUE_ENUM (*arg) = spin_button->update_policy;
break;
- case ARG_SHADOW_TYPE:
- GTK_VALUE_ENUM (*arg) = spin_button->shadow_type;
- break;
case ARG_VALUE:
GTK_VALUE_FLOAT (*arg) = spin_button->adjustment->value;
break;
{
spin_button->adjustment = NULL;
spin_button->panel = NULL;
- spin_button->shadow_type = GTK_SHADOW_NONE;
spin_button->timer = 0;
spin_button->ev_time = 0;
spin_button->climb_rate = 0.0;
if (GTK_WIDGET_DRAWABLE (widget))
{
+ GtkShadowType shadow_type;
+
/* FIXME this seems like really broken code -
* why aren't we looking at event->window
* and acting accordingly?
*/
-
- if (spin->shadow_type != GTK_SHADOW_NONE)
+
+ shadow_type = spin_button_get_shadow_type (spin);
+ if (shadow_type != GTK_SHADOW_NONE)
gtk_paint_box (widget->style, spin->panel,
- GTK_STATE_NORMAL, spin->shadow_type,
+ GTK_STATE_NORMAL, shadow_type,
&event->area, widget, "spinbutton",
0, 0,
ARROW_SIZE + 2 * widget->style->xthickness,
gtk_spin_button_draw_arrow (GtkSpinButton *spin_button,
guint arrow)
{
+ GtkShadowType spin_shadow_type;
GtkStateType state_type;
GtkShadowType shadow_type;
GtkWidget *widget;
g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button));
widget = GTK_WIDGET (spin_button);
+ spin_shadow_type = spin_button_get_shadow_type (spin_button);
if (GTK_WIDGET_DRAWABLE (spin_button))
{
}
if (arrow == GTK_ARROW_UP)
{
- if (spin_button->shadow_type != GTK_SHADOW_NONE)
+ if (spin_shadow_type != GTK_SHADOW_NONE)
{
x = widget->style->xthickness;
y = widget->style->ythickness;
}
else
{
- if (spin_button->shadow_type != GTK_SHADOW_NONE)
+ if (spin_shadow_type != GTK_SHADOW_NONE)
{
x = widget->style->xthickness;
y = widget->requisition.height / 2;
spin_button->wrap = (wrap != 0);
}
-void
-gtk_spin_button_set_shadow_type (GtkSpinButton *spin_button,
- GtkShadowType shadow_type)
+static gint
+spin_button_get_shadow_type (GtkSpinButton *spin_button)
{
- g_return_if_fail (spin_button != NULL);
- g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button));
+ GtkShadowType rc_shadow_type;
- if (shadow_type != spin_button->shadow_type)
- {
- spin_button->shadow_type = shadow_type;
- if (GTK_WIDGET_DRAWABLE (spin_button))
- gtk_widget_queue_draw (GTK_WIDGET (spin_button));
- }
+ gtk_widget_style_get (GTK_WIDGET (spin_button), "shadow_type", &rc_shadow_type, NULL);
+
+ return rc_shadow_type;
}
void
GtkAdjustment *adjustment;
GdkWindow *panel;
- GtkShadowType shadow_type;
guint32 timer;
guint32 ev_time;
void gtk_spin_button_set_wrap (GtkSpinButton *spin_button,
gboolean wrap);
-void gtk_spin_button_set_shadow_type (GtkSpinButton *spin_button,
- GtkShadowType shadow_type);
-
void gtk_spin_button_set_snap_to_ticks (GtkSpinButton *spin_button,
gboolean snap_to_ticks);
void gtk_spin_button_update (GtkSpinButton *spin_button);
#define LIGHTNESS_MULT 1.3
#define DARKNESS_MULT 0.7
-/* actually glib should do that for us */
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif /* M_PI */
-#ifndef M_PI_4
-#define M_PI_4 0.78539816339744830962
-#endif /* M_PI_4 */
-
-static void gtk_style_realize (GtkStyle *style,
- GdkColormap *colormap);
-
-static void gtk_style_real_realize (GtkStyle *style);
-static void gtk_style_real_unrealize (GtkStyle *style);
-static void gtk_style_real_copy (GtkStyle *style,
- GtkStyle *src);
-static void gtk_style_real_set_background (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type);
-static GtkStyle *gtk_style_real_clone (GtkStyle *style);
-static void gtk_style_real_init_from_rc (GtkStyle *style,
- GtkRcStyle *rc_style);
-
+/* --- typedefs & structures --- */
+typedef struct {
+ GType widget_type;
+ GParamSpec *pspec;
+ GValue value;
+} PropertyValue;
+
+
+/* --- prototypes --- */
+static void gtk_style_init (GtkStyle *style);
+static void gtk_style_class_init (GtkStyleClass *klass);
+static void gtk_style_finalize (GObject *object);
+static void gtk_style_realize (GtkStyle *style,
+ GdkColormap *colormap);
+static void gtk_style_real_realize (GtkStyle *style);
+static void gtk_style_real_unrealize (GtkStyle *style);
+static void gtk_style_real_copy (GtkStyle *style,
+ GtkStyle *src);
+static void gtk_style_real_set_background (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type);
+static GtkStyle *gtk_style_real_clone (GtkStyle *style);
+static void gtk_style_real_init_from_rc (GtkStyle *style,
+ GtkRcStyle *rc_style);
static GdkPixbuf *gtk_default_render_icon (GtkStyle *style,
const GtkIconSource *source,
GtkTextDirection direction,
GtkIconSize size,
GtkWidget *widget,
const gchar *detail);
-
static void gtk_default_draw_hline (GtkStyle *style,
GdkWindow *window,
GtkStateType state_type,
gint x,
gint y,
PangoLayout *layout);
-
-static void gtk_style_shade (GdkColor *a, GdkColor *b, gdouble k);
-static void rgb_to_hls (gdouble *r, gdouble *g, gdouble *b);
-static void hls_to_rgb (gdouble *h, gdouble *l, gdouble *s);
-
-GdkFont *default_font = NULL;
-
+static void gtk_style_shade (GdkColor *a,
+ GdkColor *b,
+ gdouble k);
+static void rgb_to_hls (gdouble *r,
+ gdouble *g,
+ gdouble *b);
+static void hls_to_rgb (gdouble *h,
+ gdouble *l,
+ gdouble *s);
+
+
+/* --- variables --- */
static GdkColor gtk_default_normal_fg = { 0, 0, 0, 0 };
static GdkColor gtk_default_active_fg = { 0, 0, 0, 0 };
static GdkColor gtk_default_prelight_fg = { 0, 0, 0, 0 };
static GdkColor gtk_default_insensitive_bg = { 0, 0xd6d6, 0xd6d6, 0xd6d6 };
static gpointer parent_class = NULL;
+static GdkFont *static_default_font = NULL;
-static void gtk_style_init (GtkStyle *style);
-static void gtk_style_class_init (GtkStyleClass *klass);
-static void gtk_style_finalize (GObject *object);
+/* --- functions --- */
GType
gtk_style_get_type (void)
{
- static GType object_type = 0;
-
- if (!object_type)
+ static GType style_type = 0;
+
+ if (!style_type)
{
- static const GTypeInfo object_info =
+ static const GTypeInfo style_info =
{
sizeof (GtkStyleClass),
(GBaseInitFunc) NULL,
(GInstanceInitFunc) gtk_style_init,
};
- object_type = g_type_register_static (G_TYPE_OBJECT,
- "GtkStyle",
- &object_info, 0);
+ style_type = g_type_register_static (G_TYPE_OBJECT,
+ "GtkStyle",
+ &style_info, 0);
}
- return object_type;
+ return style_type;
}
static void
style->font_desc = pango_font_description_from_string ("Sans 10");
- if (!default_font)
+ if (!static_default_font)
{
- default_font = gdk_font_from_description (style->font_desc);
+ static_default_font = gdk_font_from_description (style->font_desc);
- if (!default_font)
- default_font = gdk_font_load ("fixed");
+ if (!static_default_font)
+ static_default_font = gdk_font_load ("fixed");
- if (!default_font)
- g_error ("Unable to load \"fixed\" font!");
+ if (!static_default_font)
+ g_error ("Unable to load \"fixed\" font");
}
- style->font = default_font;
+ style->font = static_default_font;
gdk_font_ref (style->font);
style->attach_count = 0;
style->xthickness = 2;
style->ythickness = 2;
+
+ style->property_cache = NULL;
}
static void
GtkStyle *style = GTK_STYLE (object);
g_return_if_fail (style->attach_count == 0);
+
+ if (style->property_cache)
+ {
+ guint i;
+
+ for (i = 0; i < style->property_cache->n_nodes; i++)
+ {
+ PropertyValue *node = g_bsearch_array_get_nth (style->property_cache, i);
+
+ g_param_spec_unref (node->pspec);
+ g_value_unset (&node->value);
+ }
+ g_bsearch_array_destroy (style->property_cache);
+ style->property_cache = NULL;
+ }
if (style->styles)
{
while (tmp_list)
{
- ((GtkStyle*) tmp_list->data)->styles = style->styles->next;
+ GTK_STYLE (tmp_list->data)->styles = style->styles->next;
tmp_list = tmp_list->next;
}
g_slist_free_1 (style->styles);
iter = style->icon_factories;
while (iter != NULL)
{
- GtkIconSet *icon_set =
- gtk_icon_factory_lookup (GTK_ICON_FACTORY (iter->data),
- stock_id);
-
+ GtkIconSet *icon_set = gtk_icon_factory_lookup (GTK_ICON_FACTORY (iter->data),
+ stock_id);
if (icon_set)
return icon_set;
style->rc_style = src->rc_style;
if (src->rc_style)
gtk_rc_style_ref (src->rc_style);
+
+ /* don't copy, just clear cache */
+ if (style->property_cache)
+ {
+ guint i;
+
+ for (i = 0; i < style->property_cache->n_nodes; i++)
+ {
+ PropertyValue *node = g_bsearch_array_get_nth (style->property_cache, i);
+
+ g_param_spec_unref (node->pspec);
+ g_value_unset (&node->value);
+ }
+ g_bsearch_array_destroy (style->property_cache);
+ style->property_cache = NULL;
+ }
}
static void
GdkFont *old_font;
gint i;
+ /* cache _should_ be still empty */
+ if (style->property_cache)
+ {
+ guint i;
+
+ for (i = 0; i < style->property_cache->n_nodes; i++)
+ {
+ PropertyValue *node = g_bsearch_array_get_nth (style->property_cache, i);
+
+ g_param_spec_unref (node->pspec);
+ g_value_unset (&node->value);
+ }
+ g_bsearch_array_destroy (style->property_cache);
+ style->property_cache = NULL;
+ }
+
if (rc_style->font_desc)
{
pango_font_description_free (style->font_desc);
if (rc_style->ythickness >= 0)
style->ythickness = rc_style->ythickness;
-
if (rc_style->icon_factories)
{
GSList *iter;
}
}
+static gint
+style_property_values_cmp (gconstpointer bsearch_node1,
+ gconstpointer bsearch_node2)
+{
+ const PropertyValue *val1 = bsearch_node1;
+ const PropertyValue *val2 = bsearch_node2;
+ gint cmp;
+
+ cmp = G_BSEARCH_ARRAY_CMP (val1->widget_type, val2->widget_type);
+ if (cmp == 0)
+ cmp = G_BSEARCH_ARRAY_CMP (val1->pspec, val2->pspec);
+
+ return cmp;
+}
+
+const GValue*
+_gtk_style_peek_property_value (GtkStyle *style,
+ GType widget_type,
+ GParamSpec *pspec,
+ GtkRcPropertyParser parser)
+{
+ PropertyValue *pcache, key = { 0, NULL, { 0, } };
+ const GtkRcProperty *rcprop = NULL;
+
+ g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
+ g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), NULL);
+ g_return_val_if_fail (g_type_is_a (pspec->owner_type, GTK_TYPE_WIDGET), NULL);
+ g_return_val_if_fail (g_type_is_a (widget_type, pspec->owner_type), NULL);
+
+ /* need value cache array */
+ if (!style->property_cache)
+ style->property_cache = g_bsearch_array_new (sizeof (PropertyValue),
+ style_property_values_cmp,
+ 0);
+ /* lookup, or insert value if not yet present */
+ key.widget_type = widget_type;
+ key.pspec = pspec;
+ pcache = g_bsearch_array_insert (style->property_cache, &key, FALSE);
+ if (G_VALUE_TYPE (&pcache->value))
+ return &pcache->value;
+
+ /* cache miss, initialize value type, then set contents */
+ g_value_init (&pcache->value, G_PARAM_SPEC_VALUE_TYPE (pspec));
+
+ /* value provided by rc style? */
+ if (style->rc_style)
+ {
+ GQuark prop_quark = g_quark_from_string (pspec->name);
+
+ do
+ {
+ rcprop = _gtk_rc_style_lookup_rc_property (style->rc_style,
+ g_type_qname (widget_type),
+ prop_quark);
+ if (rcprop)
+ break;
+ widget_type = g_type_parent (widget_type);
+ }
+ while (g_type_is_a (widget_type, pspec->owner_type));
+ }
+
+ /* when supplied by rc style, we need to convert */
+ if (rcprop)
+ {
+ if (G_VALUE_TYPE (&rcprop->value) == G_TYPE_GSTRING)
+ {
+ GString *gstring;
+
+ /* value still unparsed, need to revert to user supplied parser function */
+
+ gstring = g_value_get_boxed (&rcprop->value);
+
+ if (!parser || !parser (pspec, gstring, &pcache->value) ||
+ g_param_value_validate (pspec, &pcache->value))
+ {
+ gchar *contents = g_strescape (gstring->str, NULL);
+
+ g_message ("%s: failed to parse property `%s::%s' of type `%s' from rc file value \"%s\"",
+ rcprop->origin,
+ g_type_name (pspec->owner_type), pspec->name,
+ g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
+ gstring->str);
+ g_free (contents);
+ rcprop = NULL;
+ }
+ }
+ else
+ {
+ /* we use the normal conversion functionality of param specs */
+ if (!g_param_value_convert (pspec, &rcprop->value, &pcache->value, TRUE))
+ {
+ gchar *contents = g_strdup_value_contents (&rcprop->value);
+
+ g_message ("%s: failed to retrive property `%s::%s' of type `%s' from rc file value \"%s\" of type `%s'",
+ rcprop->origin,
+ g_type_name (pspec->owner_type), pspec->name,
+ g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
+ contents,
+ G_VALUE_TYPE_NAME (&rcprop->value));
+ g_free (contents);
+ rcprop = NULL;
+ }
+ }
+ }
+
+ /* not supplied by rc style (or conversion failed), revert to default */
+ if (!rcprop)
+ g_param_value_set_default (pspec, &pcache->value);
+
+ return &pcache->value;
+}
+
static void
gtk_style_real_realize (GtkStyle *style)
{
}
else if (style->font->type == GDK_FONT_FONTSET)
{
- gc_values.font = default_font;
+ gc_values.font = static_default_font;
}
gc_values.foreground = style->black;
if (!gtk_icon_size_lookup (size, &width, &height))
{
- g_warning ("Bad icon size '%s' passed to render_icon", size);
+ g_warning (G_STRLOC ": invalid icon size `%d'", size);
return NULL;
}
gint npoints,
gboolean fill)
{
- static const gdouble pi_over_4 = M_PI_4;
- static const gdouble pi_3_over_4 = M_PI_4 * 3;
+ static const gdouble pi_over_4 = G_PI_4;
+ static const gdouble pi_3_over_4 = G_PI_4 * 3;
GdkGC *gc1;
GdkGC *gc2;
GdkGC *gc3;
extern "C" {
#endif /* __cplusplus */
-typedef struct _GtkStyle GtkStyle;
-typedef struct _GtkStyleClass GtkStyleClass;
-
#define GTK_TYPE_STYLE (gtk_style_get_type ())
#define GTK_STYLE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GTK_TYPE_STYLE, GtkStyle))
#define GTK_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_STYLE, GtkStyleClass))
/* Some forward declarations needed to rationalize the header
* files.
*/
+typedef struct _GtkStyle GtkStyle;
+typedef struct _GtkStyleClass GtkStyleClass;
typedef struct _GtkThemeEngine GtkThemeEngine;
typedef struct _GtkRcStyle GtkRcStyle;
typedef struct _GtkIconSet GtkIconSet;
typedef struct _GtkIconSource GtkIconSource;
+typedef struct _GtkRcProperty GtkRcProperty;
+typedef gboolean (*GtkRcPropertyParser) (const GParamSpec *pspec,
+ const GString *rc_string,
+ GValue *property_value);
/* We make this forward declaration here, since we pass
* GtkWidgt's to the draw functions.
*/
#define GTK_STYLE_NUM_STYLECOLORS() (7 * 5)
-#define GTK_STYLE_ATTACHED(style) (((GtkStyle*) (style))->attach_count > 0)
+#define GTK_STYLE_ATTACHED(style) (GTK_STYLE (style)->attach_count > 0)
struct _GtkStyle
{
gint depth;
GdkColormap *colormap;
- GtkRcStyle *rc_style; /* the Rc style from which this style
- * was created
- */
- GSList *styles;
+ /* the RcStyle from which this style was created */
+ GtkRcStyle *rc_style;
- GSList *icon_factories;
+ GSList *styles; /* of type GtkStyle* */
+ GBSearchArray *property_cache;
+ GSList *icon_factories; /* of type GtkIconFactory* */
};
struct _GtkStyleClass
GtkIconSet* gtk_style_lookup_icon_set (GtkStyle *style,
const gchar *stock_id);
-GdkPixbuf * gtk_style_render_icon (GtkStyle *style,
+GdkPixbuf* gtk_style_render_icon (GtkStyle *style,
const GtkIconSource *source,
GtkTextDirection direction,
GtkStateType state,
gint y,
gint width,
gint height);
-#ifndef GTK_DISABLE_DEPRECATED
-void gtk_draw_string (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- gint x,
- gint y,
- const gchar *string);
-#endif /* GTK_DISABLE_DEPRECATED */
void gtk_draw_box (GtkStyle *style,
GdkWindow *window,
GtkStateType state_type,
gint y,
gint width,
gint height);
-#ifndef GTK_DISABLE_DEPRECATED
-void gtk_paint_string (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state_type,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- gint x,
- gint y,
- const gchar *string);
-#endif /* GTK_DISABLE_DEPRECATED */
void gtk_paint_box (GtkStyle *style,
GdkWindow *window,
GtkStateType state_type,
PangoLayout *layout);
+/* --- private API --- */
+const GValue* _gtk_style_peek_property_value (GtkStyle *style,
+ GType widget_type,
+ GParamSpec *pspec,
+ GtkRcPropertyParser parser);
+
+
+/* depprecated */
+#ifndef GTK_DISABLE_DEPRECATED
+void gtk_draw_string (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ gint x,
+ gint y,
+ const gchar *string);
+void gtk_paint_string (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state_type,
+ GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ const gchar *string);
+#endif /* GTK_DISABLE_DEPRECATED */
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
#include "gtktypebuiltins_ids.c" /* type entries */
{ NULL }
};
- GTypeFundamentalInfo finfo = { 0, };
GTypeInfo tinfo = { 0, };
- GtkType type_id;
guint i;
initialized = TRUE;
#include "gtkprivate.h"
#include "gdk/gdk.h"
#include "gdk/gdkprivate.h" /* Used in gtk_reset_shapes_recurse to avoid copy */
+#include "gobject/gvaluecollector.h"
#define WIDGET_CLASS(w) GTK_WIDGET_GET_CLASS (w)
static GtkWidgetAuxInfo* gtk_widget_aux_info_new (void);
static void gtk_widget_aux_info_destroy (GtkWidgetAuxInfo *aux_info);
-static gpointer parent_class = NULL;
-static guint widget_signals[LAST_SIGNAL] = { 0 };
+static gpointer parent_class = NULL;
+static guint widget_signals[LAST_SIGNAL] = { 0 };
-static GMemChunk *aux_info_mem_chunk = NULL;
-
-static GdkColormap *default_colormap = NULL;
-static GtkStyle *gtk_default_style = NULL;
-
-static GSList *colormap_stack = NULL;
-static GSList *style_stack = NULL;
-static guint composite_child_stack = 0;
-
-static const gchar *aux_info_key = "gtk-aux-info";
-static guint aux_info_key_id = 0;
-static const gchar *event_key = "gtk-event-mask";
-static guint event_key_id = 0;
-static const gchar *extension_event_key = "gtk-extension-event-mode";
-static guint extension_event_key_id = 0;
-static const gchar *parent_window_key = "gtk-parent-window";
-static guint parent_window_key_id = 0;
-static const gchar *saved_default_style_key = "gtk-saved-default-style";
-static guint saved_default_style_key_id = 0;
-static const gchar *shape_info_key = "gtk-shape-info";
-static const gchar *colormap_key = "gtk-colormap";
-static const gchar *pango_context_key = "gtk-pango-context";
-static guint pango_context_key_id = 0;
+static GMemChunk *aux_info_mem_chunk = NULL;
+static GdkColormap *default_colormap = NULL;
+static GtkStyle *gtk_default_style = NULL;
+static GSList *colormap_stack = NULL;
+static GSList *style_stack = NULL;
+static guint composite_child_stack = 0;
+static GtkTextDirection gtk_default_direction = GTK_TEXT_DIR_LTR;
+static GParamSpecPool *style_property_spec_pool = NULL;
-static const gchar *rc_style_key = "gtk-rc-style";
-static guint rc_style_key_id = 0;
+static GQuark quark_property_parser = 0;
+static GQuark quark_aux_info = 0;
+static GQuark quark_event_mask = 0;
+static GQuark quark_extension_event_mode = 0;
+static GQuark quark_parent_window = 0;
+static GQuark quark_saved_default_style = 0;
+static GQuark quark_shape_info = 0;
+static GQuark quark_colormap = 0;
+static GQuark quark_pango_context = 0;
+static GQuark quark_rc_style = 0;
-static GtkTextDirection gtk_default_direction = GTK_TEXT_DIR_LTR;
/*****************************************
* gtk_widget_get_type:
klass->no_expose_event = NULL;
+ quark_property_parser = g_quark_from_static_string ("gtk-rc-property-parser");
+ quark_aux_info = g_quark_from_static_string ("gtk-aux-info");
+ quark_event_mask = g_quark_from_static_string ("gtk-event-mask");
+ quark_extension_event_mode = g_quark_from_static_string ("gtk-extension-event-mode");
+ quark_parent_window = g_quark_from_static_string ("gtk-parent-window");
+ quark_saved_default_style = g_quark_from_static_string ("gtk-saved-default-style");
+ quark_shape_info = g_quark_from_static_string ("gtk-shape-info");
+ quark_colormap = g_quark_from_static_string ("gtk-colormap");
+ quark_pango_context = g_quark_from_static_string ("gtk-pango-context");
+ quark_rc_style = g_quark_from_static_string ("gtk-rc-style");
+
+ style_property_spec_pool = g_param_spec_pool_new (FALSE);
+
gtk_object_add_arg_type ("GtkWidget::name", GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_NAME);
gtk_object_add_arg_type ("GtkWidget::parent", GTK_TYPE_CONTAINER, GTK_ARG_READWRITE, ARG_PARENT);
gtk_object_add_arg_type ("GtkWidget::x", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_X);
GTK_VALUE_OBJECT (*arg) = (GtkObject*) widget->parent;
break;
case ARG_X:
- aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), aux_info_key_id);
+ aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_aux_info);
if (!aux_info)
GTK_VALUE_INT (*arg) = -1;
else
GTK_VALUE_INT (*arg) = aux_info->x;
break;
case ARG_Y:
- aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), aux_info_key_id);
+ aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_aux_info);
if (!aux_info)
GTK_VALUE_INT (*arg) = -1;
else
GTK_VALUE_INT (*arg) = aux_info->y;
break;
case ARG_WIDTH:
- aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), aux_info_key_id);
+ aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_aux_info);
if (!aux_info)
GTK_VALUE_INT (*arg) = -1;
else
GTK_VALUE_INT (*arg) = aux_info->width;
break;
case ARG_HEIGHT:
- aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), aux_info_key_id);
+ aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_aux_info);
if (!aux_info)
GTK_VALUE_INT (*arg) = -1;
else
GTK_VALUE_BOXED (*arg) = (gpointer) gtk_widget_get_style (widget);
break;
case ARG_EVENTS:
- eventp = gtk_object_get_data_by_id (GTK_OBJECT (widget), event_key_id);
+ eventp = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_event_mask);
if (!eventp)
GTK_VALUE_FLAGS (*arg) = 0;
else
GTK_VALUE_FLAGS (*arg) = *eventp;
break;
case ARG_EXTENSION_EVENTS:
- modep = gtk_object_get_data_by_id (GTK_OBJECT (widget), extension_event_key_id);
+ modep = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_extension_event_mode);
if (!modep)
GTK_VALUE_FLAGS (*arg) = 0;
else
if (GTK_WIDGET_HAS_SHAPE_MASK (widget))
{
- shape_info = gtk_object_get_data (GTK_OBJECT (widget),
- shape_info_key);
+ shape_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_shape_info);
gdk_window_shape_combine_mask (widget->window,
shape_info->shape_mask,
shape_info->offset_x,
*requisition = widget->requisition;
- aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), aux_info_key_id);
+ aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_aux_info);
if (aux_info)
{
if (aux_info->width > 0)
g_return_if_fail (GTK_IS_WIDGET (widget));
real_allocation = *allocation;
- aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), aux_info_key_id);
+ aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_aux_info);
if (aux_info)
{
GTK_WIDGET_UNSET_FLAGS (widget, GTK_RC_STYLE);
GTK_PRIVATE_SET_FLAG (widget, GTK_USER_STYLE);
- default_style = gtk_object_get_data_by_id (GTK_OBJECT (widget), saved_default_style_key_id);
+ default_style = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_saved_default_style);
if (!default_style)
{
gtk_style_ref (widget->style);
- if (!saved_default_style_key_id)
- saved_default_style_key_id = g_quark_from_static_string (saved_default_style_key);
- gtk_object_set_data_by_id (GTK_OBJECT (widget), saved_default_style_key_id, widget->style);
+ gtk_object_set_data_by_id (GTK_OBJECT (widget), quark_saved_default_style, widget->style);
}
gtk_widget_set_style_internal (widget, style, initial_emission);
GTK_PRIVATE_UNSET_FLAG (widget, GTK_USER_STYLE);
GTK_WIDGET_SET_FLAGS (widget, GTK_RC_STYLE);
- saved_style = gtk_object_get_data_by_id (GTK_OBJECT (widget), saved_default_style_key_id);
+ saved_style = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_saved_default_style);
new_style = gtk_rc_get_style (widget);
if (new_style)
{
if (!saved_style)
{
gtk_style_ref (widget->style);
- if (!saved_default_style_key_id)
- saved_default_style_key_id = g_quark_from_static_string (saved_default_style_key);
- gtk_object_set_data_by_id (GTK_OBJECT (widget), saved_default_style_key_id, widget->style);
+ gtk_object_set_data_by_id (GTK_OBJECT (widget), quark_saved_default_style, widget->style);
}
gtk_widget_set_style_internal (widget, new_style, initial_emission);
}
{
g_assert (initial_emission == FALSE); /* FIXME: remove this line */
- gtk_object_remove_data_by_id (GTK_OBJECT (widget), saved_default_style_key_id);
+ gtk_object_remove_data_by_id (GTK_OBJECT (widget), quark_saved_default_style);
gtk_widget_set_style_internal (widget, saved_style, initial_emission);
gtk_style_unref (saved_style);
}
GTK_PRIVATE_UNSET_FLAG (widget, GTK_USER_STYLE);
- default_style = gtk_object_get_data_by_id (GTK_OBJECT (widget), saved_default_style_key_id);
+ default_style = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_saved_default_style);
if (default_style)
{
- gtk_object_remove_data_by_id (GTK_OBJECT (widget), saved_default_style_key_id);
+ gtk_object_remove_data_by_id (GTK_OBJECT (widget), quark_saved_default_style);
gtk_widget_set_style_internal (widget, default_style, FALSE);
gtk_style_unref (default_style);
}
g_return_if_fail (GTK_IS_RC_STYLE (style));
- if (!rc_style_key_id)
- rc_style_key_id = g_quark_from_static_string (rc_style_key);
-
old_style = gtk_object_get_data_by_id (GTK_OBJECT (widget),
- rc_style_key_id);
+ quark_rc_style);
if (style != old_style)
gtk_object_set_data_by_id_full (GTK_OBJECT (widget),
- rc_style_key_id,
+ quark_rc_style,
gtk_rc_style_copy (style),
(GtkDestroyNotify)gtk_rc_style_unref);
{
GtkRcStyle *rc_style;
- if (!rc_style_key_id)
- rc_style_key_id = g_quark_from_static_string (rc_style_key);
-
rc_style = gtk_object_get_data_by_id (GTK_OBJECT (widget),
- rc_style_key_id);
+ quark_rc_style);
if (!rc_style)
{
rc_style = gtk_rc_style_new();
gtk_object_set_data_by_id_full (GTK_OBJECT (widget),
- rc_style_key_id,
+ quark_rc_style,
rc_style,
(GtkDestroyNotify)gtk_rc_style_unref);
}
static PangoContext *
gtk_widget_peek_pango_context (GtkWidget *widget)
{
- if (!pango_context_key_id)
- pango_context_key_id = g_quark_from_static_string (pango_context_key);
-
- return gtk_object_get_data_by_id (GTK_OBJECT (widget), pango_context_key_id);
+ return gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_pango_context);
}
/**
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
- if (!pango_context_key_id)
- pango_context_key_id = g_quark_from_static_string (pango_context_key);
-
- context = gtk_object_get_data_by_id (GTK_OBJECT (widget), pango_context_key_id);
+ context = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_pango_context);
if (!context)
{
context = gtk_widget_create_pango_context (GTK_WIDGET (widget));
- gtk_object_set_data_by_id_full (GTK_OBJECT (widget), pango_context_key_id, context,
- (GDestroyNotify)g_object_unref);
+ gtk_object_set_data_by_id_full (GTK_OBJECT (widget), quark_pango_context, context,
+ (GDestroyNotify) g_object_unref);
}
return context;
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
g_return_val_if_fail (stock_id != NULL, NULL);
- g_return_val_if_fail (size != NULL, NULL);
+ g_return_val_if_fail (size > GTK_ICON_SIZE_INVALID, NULL);
gtk_widget_ensure_style (widget);
g_return_if_fail (GTK_IS_WIDGET (widget));
old_parent_window = gtk_object_get_data_by_id (GTK_OBJECT (widget),
- parent_window_key_id);
+ quark_parent_window);
if (parent_window != old_parent_window)
{
- if (!parent_window_key_id)
- parent_window_key_id = g_quark_from_static_string (parent_window_key);
- gtk_object_set_data_by_id (GTK_OBJECT (widget), parent_window_key_id,
+ gtk_object_set_data_by_id (GTK_OBJECT (widget), quark_parent_window,
parent_window);
if (old_parent_window)
gdk_window_unref (old_parent_window);
g_return_val_if_fail (widget->parent != NULL, NULL);
parent_window = gtk_object_get_data_by_id (GTK_OBJECT (widget),
- parent_window_key_id);
+ quark_parent_window);
return (parent_window != NULL) ? parent_window : widget->parent->window;
}
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
- aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), aux_info_key_id);
+ aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_aux_info);
if (!aux_info)
{
- if (!aux_info_key_id)
- aux_info_key_id = g_quark_from_static_string (aux_info_key);
aux_info = gtk_widget_aux_info_new ();
- gtk_object_set_data_by_id (GTK_OBJECT (widget), aux_info_key_id, aux_info);
+ gtk_object_set_data_by_id (GTK_OBJECT (widget), quark_aux_info, aux_info);
}
/* keep this in sync with gtk_window_compute_reposition() */
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
- aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), aux_info_key_id);
+ aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_aux_info);
if (!aux_info)
{
- if (!aux_info_key_id)
- aux_info_key_id = g_quark_from_static_string (aux_info_key);
aux_info = gtk_widget_aux_info_new ();
- gtk_object_set_data_by_id (GTK_OBJECT (widget), aux_info_key_id, aux_info);
+ gtk_object_set_data_by_id (GTK_OBJECT (widget), quark_aux_info, aux_info);
}
if (width > -2)
g_return_if_fail (!GTK_WIDGET_NO_WINDOW (widget));
g_return_if_fail (!GTK_WIDGET_REALIZED (widget));
- eventp = gtk_object_get_data_by_id (GTK_OBJECT (widget), event_key_id);
+ eventp = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_event_mask);
if (events)
{
eventp = g_new (gint, 1);
*eventp = events;
- if (!event_key_id)
- event_key_id = g_quark_from_static_string (event_key);
- gtk_object_set_data_by_id (GTK_OBJECT (widget), event_key_id, eventp);
+ gtk_object_set_data_by_id (GTK_OBJECT (widget), quark_event_mask, eventp);
}
else if (eventp)
{
g_free (eventp);
- gtk_object_remove_data_by_id (GTK_OBJECT (widget), event_key_id);
+ gtk_object_remove_data_by_id (GTK_OBJECT (widget), quark_event_mask);
}
}
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (!GTK_WIDGET_NO_WINDOW (widget));
- eventp = gtk_object_get_data_by_id (GTK_OBJECT (widget), event_key_id);
+ eventp = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_event_mask);
if (events)
{
}
*eventp |= events;
- if (!event_key_id)
- event_key_id = g_quark_from_static_string (event_key);
- gtk_object_set_data_by_id (GTK_OBJECT (widget), event_key_id, eventp);
+ gtk_object_set_data_by_id (GTK_OBJECT (widget), quark_event_mask, eventp);
}
else if (eventp)
{
g_free (eventp);
- gtk_object_remove_data_by_id (GTK_OBJECT (widget), event_key_id);
+ gtk_object_remove_data_by_id (GTK_OBJECT (widget), quark_event_mask);
}
if (GTK_WIDGET_REALIZED (widget))
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
- modep = gtk_object_get_data_by_id (GTK_OBJECT (widget), extension_event_key_id);
+ modep = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_extension_event_mode);
if (!modep)
modep = g_new (GdkExtensionMode, 1);
*modep = mode;
- if (!extension_event_key_id)
- extension_event_key_id = g_quark_from_static_string (extension_event_key);
- gtk_object_set_data_by_id (GTK_OBJECT (widget), extension_event_key_id, modep);
+ gtk_object_set_data_by_id (GTK_OBJECT (widget), quark_extension_event_mode, modep);
}
/**
return colormap;
}
- colormap = gtk_object_get_data (GTK_OBJECT (widget), colormap_key);
+ colormap = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_colormap);
if (colormap)
return colormap;
g_object_ref (G_OBJECT (colormap));
- gtk_object_set_data_full (GTK_OBJECT (widget),
- colormap_key,
- colormap,
- (GtkDestroyNotify) g_object_unref);
+ g_object_set_qdata_full (G_OBJECT (widget),
+ quark_colormap,
+ colormap,
+ (GtkDestroyNotify) g_object_unref);
}
/**
g_return_val_if_fail (widget != NULL, 0);
g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
- events = gtk_object_get_data_by_id (GTK_OBJECT (widget), event_key_id);
+ events = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_event_mask);
if (events)
return *events;
g_return_val_if_fail (widget != NULL, 0);
g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
- mode = gtk_object_get_data_by_id (GTK_OBJECT (widget), extension_event_key_id);
+ mode = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_extension_event_mode);
if (mode)
return *mode;
gtk_grab_remove (widget);
gtk_selection_remove_all (widget);
- saved_style = gtk_object_get_data_by_id (object, saved_default_style_key_id);
+ saved_style = gtk_object_get_data_by_id (object, quark_saved_default_style);
if (saved_style)
{
gtk_style_unref (saved_style);
- gtk_object_remove_data_by_id (object, saved_default_style_key_id);
+ gtk_object_remove_data_by_id (object, quark_saved_default_style);
}
gtk_style_unref (widget->style);
gtk_grab_remove (widget);
gtk_selection_remove_all (widget);
- saved_style = gtk_object_get_data_by_id (GTK_OBJECT (widget), saved_default_style_key_id);
+ saved_style = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_saved_default_style);
if (saved_style)
{
gtk_style_unref (saved_style);
- gtk_object_remove_data_by_id (GTK_OBJECT (widget), saved_default_style_key_id);
+ gtk_object_remove_data_by_id (GTK_OBJECT (widget), quark_saved_default_style);
}
gtk_style_unref (widget->style);
if (widget->name)
g_free (widget->name);
- aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), aux_info_key_id);
+ aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_aux_info);
if (aux_info)
gtk_widget_aux_info_destroy (aux_info);
- events = gtk_object_get_data_by_id (GTK_OBJECT (widget), event_key_id);
+ events = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_event_mask);
if (events)
g_free (events);
- mode = gtk_object_get_data_by_id (GTK_OBJECT (widget), extension_event_key_id);
+ mode = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_extension_event_mode);
if (mode)
g_free (mode);
if (widget->window)
gdk_window_shape_combine_mask (widget->window, NULL, 0, 0);
- gtk_object_remove_data (GTK_OBJECT (widget), shape_info_key);
+ g_object_set_qdata (G_OBJECT (widget), quark_shape_info, NULL);
}
else
{
GTK_PRIVATE_SET_FLAG (widget, GTK_HAS_SHAPE_MASK);
shape_info = g_new (GtkWidgetShapeInfo, 1);
- gtk_object_set_data_full (GTK_OBJECT (widget), shape_info_key, shape_info,
- (GDestroyNotify)gtk_widget_shape_info_destroy);
+ g_object_set_qdata_full (G_OBJECT (widget), quark_shape_info, shape_info,
+ (GDestroyNotify) gtk_widget_shape_info_destroy);
shape_info->shape_mask = gdk_drawable_ref (shape_mask);
shape_info->offset_x = offset_x;
g_object_unref ((GObject*) widget);
}
+
+/* style properties
+ */
+
+void
+gtk_widget_class_install_style_property_parser (GtkWidgetClass *class,
+ GParamSpec *pspec,
+ GtkRcPropertyParser parser)
+{
+ g_return_if_fail (GTK_IS_WIDGET_CLASS (class));
+ g_return_if_fail (G_IS_PARAM_SPEC (pspec));
+ g_return_if_fail (pspec->flags & G_PARAM_READABLE);
+ g_return_if_fail (!(pspec->flags & (G_PARAM_CONSTRUCT_ONLY | G_PARAM_CONSTRUCT)));
+
+ if (g_param_spec_pool_lookup (style_property_spec_pool, pspec->name, G_OBJECT_CLASS_TYPE (class), FALSE))
+ {
+ g_warning (G_STRLOC ": class `%s' already contains a style property named `%s'",
+ G_OBJECT_CLASS_NAME (class),
+ pspec->name);
+ return;
+ }
+
+ g_param_spec_ref (pspec);
+ g_param_spec_sink (pspec);
+ g_param_spec_set_qdata (pspec, quark_property_parser, parser);
+ g_param_spec_pool_insert (style_property_spec_pool, pspec, G_OBJECT_CLASS_TYPE (class));
+}
+
+void
+gtk_widget_class_install_style_property (GtkWidgetClass *class,
+ GParamSpec *pspec)
+{
+ gtk_widget_class_install_style_property_parser (class, pspec, NULL);
+}
+
+void
+gtk_widget_style_get_property (GtkWidget *widget,
+ const gchar *property_name,
+ GValue *value)
+{
+ GParamSpec *pspec;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (property_name != NULL);
+ g_return_if_fail (G_IS_VALUE (value));
+
+ g_object_ref (widget);
+ pspec = g_param_spec_pool_lookup (style_property_spec_pool,
+ property_name,
+ G_OBJECT_TYPE (widget),
+ TRUE);
+ if (!pspec)
+ g_warning ("%s: widget class `%s' has no property named `%s'",
+ G_STRLOC,
+ G_OBJECT_TYPE_NAME (widget),
+ property_name);
+ else
+ {
+ const GValue *peek_value;
+
+ peek_value = _gtk_style_peek_property_value (widget->style,
+ G_OBJECT_TYPE (widget),
+ pspec,
+ g_param_spec_get_qdata (pspec, quark_property_parser));
+
+ /* auto-conversion of the caller's value type
+ */
+ if (G_VALUE_TYPE (value) == G_PARAM_SPEC_VALUE_TYPE (pspec))
+ g_value_copy (peek_value, value);
+ else if (g_value_type_transformable (G_PARAM_SPEC_VALUE_TYPE (pspec), G_VALUE_TYPE (value)))
+ g_value_transform (peek_value, value);
+ else
+ g_warning ("can't retrive style property `%s' of type `%s' as value of type `%s'",
+ pspec->name,
+ g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
+ G_VALUE_TYPE_NAME (value));
+ }
+ g_object_unref (widget);
+}
+
+void
+gtk_widget_style_get_valist (GtkWidget *widget,
+ const gchar *first_property_name,
+ va_list var_args)
+{
+ const gchar *name;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ g_object_ref (widget);
+
+ name = first_property_name;
+ while (name)
+ {
+ const GValue *peek_value;
+ GParamSpec *pspec;
+ gchar *error;
+
+ pspec = g_param_spec_pool_lookup (style_property_spec_pool,
+ name,
+ G_OBJECT_TYPE (widget),
+ TRUE);
+ if (!pspec)
+ {
+ g_warning ("%s: widget class `%s' has no property named `%s'",
+ G_STRLOC,
+ G_OBJECT_TYPE_NAME (widget),
+ name);
+ break;
+ }
+ /* style pspecs are always readable so we can spare that check here */
+
+ peek_value = _gtk_style_peek_property_value (widget->style,
+ G_OBJECT_TYPE (widget),
+ pspec,
+ g_param_spec_get_qdata (pspec, quark_property_parser));
+ G_VALUE_LCOPY (peek_value, var_args, G_VALUE_NOCOPY_CONTENTS, &error);
+ if (error)
+ {
+ g_warning ("%s: %s", G_STRLOC, error);
+ g_free (error);
+ break;
+ }
+
+ name = va_arg (var_args, gchar*);
+ }
+
+ g_object_unref (widget);
+}
+
+void
+gtk_widget_style_get (GtkWidget *widget,
+ const gchar *first_property_name,
+ ...)
+{
+ va_list var_args;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ va_start (var_args, first_property_name);
+ gtk_widget_style_get_valist (widget, first_property_name, var_args);
+ va_end (var_args);
+}
+
/**
* gtk_widget_path:
* @widget: a #GtkWidget
*/
#define GTK_WIDGET_SET_FLAGS(wid,flag) G_STMT_START{ (GTK_WIDGET_FLAGS (wid) |= (flag)); }G_STMT_END
#define GTK_WIDGET_UNSET_FLAGS(wid,flag) G_STMT_START{ (GTK_WIDGET_FLAGS (wid) &= ~(flag)); }G_STMT_END
-
-
-
-typedef struct _GtkRequisition GtkRequisition;
-typedef struct _GdkRectangle GtkAllocation;
-typedef struct _GtkSelectionData GtkSelectionData;
-typedef struct _GtkWidgetClass GtkWidgetClass;
-typedef struct _GtkWidgetAuxInfo GtkWidgetAuxInfo;
-typedef struct _GtkWidgetShapeInfo GtkWidgetShapeInfo;
-typedef void (*GtkCallback) (GtkWidget *widget,
- gpointer data);
+
+/* forward declaration to avoid excessive includes (and concurrent includes)
+ */
+typedef struct _GtkRequisition GtkRequisition;
+typedef struct _GdkRectangle GtkAllocation;
+typedef struct _GtkSelectionData GtkSelectionData;
+typedef struct _GtkWidgetClass GtkWidgetClass;
+typedef struct _GtkWidgetAuxInfo GtkWidgetAuxInfo;
+typedef struct _GtkWidgetShapeInfo GtkWidgetShapeInfo;
+typedef void (*GtkCallback) (GtkWidget *widget,
+ gpointer data);
/* A requisition is a desired amount of space which a
* widget may request.
void gtk_widget_pop_style (void);
void gtk_widget_pop_colormap (void);
+/* widget style properties
+ */
+void gtk_widget_class_install_style_property (GtkWidgetClass *class,
+ GParamSpec *pspec);
+void gtk_widget_class_install_style_property_parser (GtkWidgetClass *class,
+ GParamSpec *pspec,
+ GtkRcPropertyParser parser);
+void gtk_widget_style_get_property (GtkWidget *widget,
+ const gchar *property_name,
+ GValue *value);
+void gtk_widget_style_get_valist (GtkWidget *widget,
+ const gchar *first_property_name,
+ va_list var_args);
+void gtk_widget_style_get (GtkWidget *widget,
+ const gchar *first_property_name,
+ ...);
+
+
/* Set certain default values to be used at widget creation time.
*/
void gtk_widget_set_default_style (GtkStyle *style);
g_free (window->wmclass_name);
g_free (window->wmclass_class);
- G_OBJECT_CLASS(parent_class)->finalize (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
# On Windows, if you have installed gtk-engines, try this for instance:
#include "\\windows\\gtk\\themes\\Pixmap\\gtk\\gtkrc"
-#foo_number = 5
-#mouse_timeout = -7
+double-click_timeout = 42
+bell-duration = 39
+bell_duration = 40
pixmap_path "."
+style "global-style-properties"
+{
+# xthickness = 20
+ GtkSpinButton::shadow_type = etched-out
+}
+class "GtkWidget" style "global-style-properties"
+
style "defaultfont"
{
font_name = "Sans 12"
+
+ Gtest::foo = 47
+ Gtest::bar = 47
+# GtkScrollbar::spacing = 33
+# GtkButton::color = { 3, 2,45, 6, 6, 4, 23 }
}
style "myicons"
# On Windows, if you have installed gtk-engines, try this for instance:
#include "\\windows\\gtk\\themes\\Pixmap\\gtk\\gtkrc"
-#foo_number = 5
-#mouse_timeout = -7
+double-click_timeout = 42
+bell-duration = 39
+bell_duration = 40
pixmap_path "."
+style "global-style-properties"
+{
+# xthickness = 20
+ GtkSpinButton::shadow_type = etched-out
+}
+class "GtkWidget" style "global-style-properties"
+
style "defaultfont"
{
font_name = "Sans 12"
+
+ Gtest::foo = 47
+ Gtest::bar = 47
+# GtkScrollbar::spacing = 33
+# GtkButton::color = { 3, 2,45, 6, 6, 4, 23 }
}
style "myicons"